myITforum.com Community Forum myITforum.com Community Forum

Home  Forums  Blogs  Live Support chat  Search Articles  Wiki  FAQ  Email Lists  Register  Login  My Profile  Inbox  Address Book  My Subscription  My Forums 

Photo Gallery  Member List  Search  Calendars  FAQ  Ticket List  Log Out

All Forums RSS Feed Subscription:


  


ADSI WinPE Functionality Not Working

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
  Printable Version
All Forums >> [Management Products] >> System Center Products >> System Center Configuration Manager >> ADSI WinPE Functionality Not Working Page: [1]
Login
Message << Older Topic   Newer Topic >>
ADSI WinPE Functionality Not Working - 11/15/2008 3:27:13 PM   
sbond293

 

Posts: 108
Score: 2
Joined: 9/4/2006
Status: offline
I am putting together a slightly prettier front end for SCCM than I am currently running and in doing so I am experimenting with something I found on the MS Scripting Guys column which lists the OUs in your domain in an HTA. I have updated it very slightly but essentially the problem I have is that I am getting a 'table does not exist' error on line 22 (Set objRecordSet = objCommand.Execute).
I have added the extra connection properties as it simply freezes in WinPE without this but gets the error above with.
This script however works perfectly in normal Windows. I have created a custom PE image which has ADO support so can anyone explain the problem? My code is below. I know this does nothing more than simply display the OU structure as it stands (I'll add the additional functionality if/when I get it working).
Thank you
SCRIPT (HTA):
<SCRIPT Language="VBScript">
   Sub Window_onLoad
       'On Error Resume Next

        Const ADS_SCOPE_SUBTREE = 2
        Set objConnection = CreateObject("ADODB.Connection")
       Set objCommand =   CreateObject("ADODB.Command")
       objConnection.Provider = "ADsDSOObject"
objConnection.Properties("User ID") = "DOMAIN\Administrator"
objConnection.Properties("Password") = "password"
'objConnection.Properties("ADSI Flag") = 1


       objConnection.Open "Active Directory Provider"
       Set objCommand.ActiveConnection = objConnection
       objCommand.Properties("Page Size") = 1000
       objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
       objCommand.CommandText = "SELECT Name, ADsPath FROM 'LDAP://OU=MY OU,dc=MYDC,dc=net'" & " WHERE objectCategory='organizationalUnit' ORDER BY Name" 
       Set objRecordSet = objCommand.Execute
       objRecordSet.MoveFirst
       Do Until objRecordSet.EOF
           Set objOption = Document.createElement("OPTION")
           objOption.Text = objRecordSet.Fields("Name").Value
           objOption.Value = objRecordSet.Fields("ADsPath").Value
           AvailableOUs.Add(objOption)
           objRecordSet.MoveNext
       Loop
   End Sub
   Sub ShowOUPath
       Msgbox AvailableOUs.Value
   End Sub
</SCRIPT>
<body>
   <select size="10" name="AvailableOUs" style="width:300"></select><p>
   <input id=runbutton type="button" value="Show OU Path" onClick="ShowOUPath">
</body>
Post #: 1
RE: ADSI WinPE Functionality Not Working - 11/15/2008 3:49:05 PM   
mniehaus


Posts: 218
Score: 11
Joined: 6/4/2001
From: Michael Niehaus
Status: offline
Windows PE does not include ADSI support or the OLE DB ADSI provider, and there's no supported way to add them. There are some articles on the web that describe how to get basic ADSI functionality added, but that probably won't enable the OLE DB provider.

-Michael Niehaus
Senior Software Development Engineer
mniehaus@microsoft.com

(in reply to sbond293)
Post #: 2
RE: ADSI WinPE Functionality Not Working - 11/15/2008 5:21:11 PM   
sbond293

 

Posts: 108
Score: 2
Joined: 9/4/2006
Status: offline
Thanks, looks like I'll have to take a different approach.

(in reply to mniehaus)
Post #: 3
RE: ADSI WinPE Functionality Not Working - 11/16/2008 1:13:24 PM   
sbond293

 

Posts: 108
Score: 2
Joined: 9/4/2006
Status: offline
OK what I'd like to do (if indeed it is possible) is run a VB6 front end which will read a text file containing my OU structure and display it in a drop down list along with a text box for the computer name.
This part is easy enough but how do I reference ZTIUTILIY.vbs from within the VB6 app as you would in an HTA (src="X:\ZTIUtility.vbs") in order to carry over OSDNewMachineName, OSDDomainOUName, etc to the new system?
Thank you.

(in reply to sbond293)
Post #: 4
RE: ADSI WinPE Functionality Not Working - 11/16/2008 2:10:41 PM   
sbond293

 

Posts: 108
Score: 2
Joined: 9/4/2006
Status: offline
In anticipation of being shot down in flames for considering using a VB6 front end (partly as I am having trouble executing it in WinPE) I have an HTA alternative I have also been working on. The basic script is as follows:

FRONTEND.hta
<job id="ZTIPromptForComputerName">
  <script language="VBScript" src="ZTIUtility.vbs"/>
  <script language="VBScript">

Sub Window_Onload
   ForReading = 1
   strNewFile = "computerOUs.txt"
   Set objFSO = CreateObject("Scripting.FileSystemObject")
   Set objFile = objFSO.OpenTextFile _
       (strNewFile, ForReading)
   Do Until objFile.AtEndOfStream
       strLine = objFile.ReadLine
       Set objOption = Document.createElement("OPTION")
       objOption.Text = strLine
       objOption.Value = strLine
       ComputerOU.Add(objOption)
   Loop
   objFile.Close
End Sub

Sub ShowOUPath

oEnvironment.Item("OSDDomainOUName") = "OU=" & ComputerOU.Value & ",OU=XXX,DC=YYY,DC=ZZZ"
oEnvironment.Item("OSDNEWMACHINENAME") = ComputerName.Value
MsgBox "OU=" & ComputerOU.Value & ",OU=XXX,DC=YYY,DC=ZZZ" & vbCrLf &_
"Computer Name = " & ComputerName.Value

End Sub
</SCRIPT>

<body>
   <select size="10" name="ComputerOU" style="width:300"></select><p>
   <input type="text" name="ComputerName" size="45"><p>
   <input id=runbutton type="button" value="Build Machine" onClick="ShowOUPath">
</body>
</job>

This seems to work fine as long as I miss out the line:
<script language="VBScript" src="ZTIUtility.vbs"/>
With the inclusion of ZTIUtility reference, the contents of the computerOUs.txt no longer seems to be iterated. Any idea why this might be?

Thank you.

(in reply to sbond293)
Post #: 5
RE: ADSI WinPE Functionality Not Working - 11/16/2008 5:27:15 PM   
sbond293

 

Posts: 108
Score: 2
Joined: 9/4/2006
Status: offline
OK, finally nailed this with reference to an answer from one of my previous posts. Still unsure why it won't work with ZTIUtility.vbs reference, but the point is it isn't needed. Instead under the Sub ShowOUPath, enter the following:
 
SET oEnvironment = CreateObject("Microsoft.SMS.TSEnvironment")
oEnvironment("OSDComputerName") = computername.Value

etc, etc 

Any variables set under oEnvironment are then passed on during build time.
Thank you

(in reply to sbond293)
Post #: 6
Page:   [1]
All Forums >> [Management Products] >> System Center Products >> System Center Configuration Manager >> ADSI WinPE Functionality Not Working Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts



  
Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.781