How to pass encrypted password to objSWbemLocator.ConnectServer?

Answered How to pass encrypted password to objSWbemLocator.ConnectServer?

  • Monday, March 04, 2013 10:25 PM
     
     

    Please help. See below <Password>. I want to pass only encrypted password only. How to achieve this?

    sServer = "<RemoreServerName>"    


    Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")

    Set objSWbemServices = objSWbemLocator.ConnectServer(sServer, "root\cimv2", "<UserName>", "<Password>")

    Set objProcess = objSWbemServices.Get("Win32_Process")

    errReturn = objProcess.Create("C:\Scripts\test1.bat", Null, Null, intProcessID) 

    If errReturn <> 0 Then
      msgbox "It could not be started due to error: " & errReturn
    End If  

All Replies

  • Monday, March 04, 2013 10:42 PM
     
     Answered

    You can't.  It takes a plain text password.  Paswords are passed encrypted if teh conenction supports encryption but you must start with a plain text password.

    You can use Get-WmiObject in PowerShell and pass credentials.

    Get-WmiObject Win32_Process -computer $server -credential $cred


    ¯\_(ツ)_/¯


  • Tuesday, March 05, 2013 3:24 AM
     
     

    ok. Can  $cred take encrypted password one?

  • Tuesday, March 05, 2013 3:41 PM
    Moderator
     
     

    Can you rephrase your last question? I don't understand it.

    Bill