|
There is the way to pass user's credentials with ADSI like this: $oComputer = getobject("WinNT:").OpenDSObject("WinNT://"+$computer+",computer",$user,$password, 2) Is there alike way to do that with WMI call? Standard call $objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" + $Computer + "\root\cimv2") produces "Access is denied" message.
I found a decsription of impersonation levels, but how to use it? Impersonation Levels: wbemImpersonationLevelAnonymous: 1 - Hides the credentials of the caller. Calls to WMI may fail with this impersonation level. wbemImpersonationLevelIdentify: 2 - Allows objects to query the credentials of the caller. Calls to WMI may fail with this impersonation level. wbemImpersonationLevelImpersonate: 3 - Allows objects to use the credentials of the caller. This is the recommended impersonation level for WMI Scripting API calls. wbemImpersonationLevelDelegate: 4 - Allows objects to permit other objects to use the credentials of the caller. This impersonation, which will work with WMI Scripting API calls but may constitute an unnecessary security risk, is supported only under Windows 2000.
|