Deployment Solution

 View Only
Expand all | Collapse all

Accessing ASDK COM objects thru SWbemLocator DS7.1 SP1

  • 1.  Accessing ASDK COM objects thru SWbemLocator DS7.1 SP1

    Posted Jun 29, 2011 01:07 PM

    I'm trying to remotely predefine a computer and retrieve the computer GUID (in order to schedule a job to be run when that computer checks in).  I'm using vbscript and SWBemLocator in WinPE to launch another test vbscript stored locally on the DS. So far, I have not been able to retrieve the computer GUID when I do this.  I have NO problem when I run the local script from a command prompt on the DS.  The local script creates a predefined computer & sends the input XML, output XML, and success status to a text file.  Then it checks the predefined computers list for GUIDs and writes results to the text file.

    When I run the script remotely, the computer definition works fine and partial information is written to the txt file....no GUID in the returnXML.  No GUID information is returned when the script retrieves the "DSOH_PredefinedComputers" info.  When I run the same script from a command prompt on the DS, the GUID information shows up fine.  Any ideas?

    This is run in WinPE to remotely launch the test script on the DS:

    strDSName = "<dsname>"
    DeploymentLID = "<id>"
    DeploymentPWD = "<password>"
    scriptName = "test.vbs"
    scriptPath = "<path>"

    Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
    Set objSWbemServices = objSWbemLocator.ConnectServer(strDSName, "root\cimv2", strDSName & "\" & DeploymentLID, DeploymentPWD)
    objSWbemServices.Security_.ImpersonationLevel = 3
    objSWbemServices.Security_.AuthenticationLevel = 6
    Set objProcess = objSWbemServices.Get("Win32_Process")
    SubJobCmd = "Wscript.exe " & Chr(34) & scriptPath & scriptName & Chr(34)
    SubJobRtn = objProcess.Create(SubJobCmd, Null, Null, intProcessID)
    If SubJobRtn <> 0 Then
        MsgBox "Error Adding the Computer Account on DS"
    End If

    This is what's run locally on the DS.  Taken from the ASDK AddPredefinedComputers.vbs script & modified to taste:

    '---------------------------------------
    ' Set up the management object(s).
    '---------------------------------------
    set dsManagement = CreateObject("Altiris.ASDK.DeploymentSolution.DSTaskManagement")

    dsManagement.CreateLocalInstance()

    '---------------------------------------
    ' Additional variables
    '---------------------------------------
    Dim dsDetails
    computerName = "<dsserver>"

    Set objFso = CreateObject("Scripting.FileSystemObject")
    Set objCmpLog = objFSO.OpenTextFile("\\" & computerName & "<path>\Test-CMP.Log", 2, True, 0)

    '---------------------------------------
    ' Call to add predefined computers.
    '---------------------------------------
    objCmpLog.WriteLine "Calling Add_PredefinedComputers"
    call Add_PredefinedComputers( computerName, dsDetails )
    objCmpLog.WriteLine "Return Xml: " & vbcrlf & dsDetails.ReturnXml
    objCmpLog.WriteLine "Success: " & dsDetails.Success
    objCmpLog.WriteLine "Method complete"

    '---------------------------------------
    ' Call to predefined computers.
    '---------------------------------------
    objCmpLog.WriteLine "Calling Parse_Add_PredefinedComputers_Output"
    Parse_Add_PredefinedComputers_Output( dsDetails )
    objCmpLog.WriteLine "Method complete"
    objCmpLog.WriteLine "Done"

    '----------------------------------------------------
    ' Sub Add_PredefinedComputers
    '----------------------------------------------------
    Sub Add_PredefinedComputers( computerName, ByRef dsDetails )

     '----------------------------------------------------
     'Following code is for "add" action type.
     '----------------------------------------------------
      set objAddPredefinedComputers = CreateObject( "Altiris.ASDK.DeploymentSolution.DSH_AddPredefinedComputers" )
      filePath = "\\" & computerName & "<path>\Test-CMP.csv"
      objAddPredefinedComputers.FilePath = filePath

     '----------------------------------------------------
     ' Get the input XML string.
     '----------------------------------------------------
      inputXml = objAddPredefinedComputers.ToString("add")
      objCmpLog.WriteLine "Input XML: " & vbcrlf & inputXml
      set dsDetails = dsManagement.RunDeploymentSolutionTask( inputXml )
    end Sub

    '----------------------------------------------------
    ' Sub Parse_Add_PredefinedComputers_Output
    '----------------------------------------------------
    Sub Parse_Add_PredefinedComputers_Output( dsDetails )

     '----------------------------------------------------
     'Following code is for "add" action type.
     '----------------------------------------------------
      set object = CreateObject( "Altiris.ASDK.DeploymentSolution.DSOH_PredefinedComputers" )
      call object.Deserialize( dsDetails, "add")
     
     '----------------------------------------------------
     ' Loop over each array element using "for each".
     '----------------------------------------------------
      if ( UBound(object.Guids() ) < 0 ) then
        objCmpLog.WriteLine "There is no data to display."
        exit Sub
      end if
     
      dim computerGuid
      outputString = ""
      for each computerGuid in object.Guids()
        outputString = outputString & "Guid : " & computerGuid & vbcrlf
        objCmpLog.WriteLine "outputString:" & outputString
        outputString = ""
      next
    end Sub



  • 2.  RE: Accessing ASDK COM objects thru SWbemLocator DS7.1 SP1

    Posted Jul 06, 2011 11:58 AM

    *bump*

    Any ideas? This is a show-stopper for me.