with the original piece of code published, you have to be connected on the workstation with a domain account
that has admin right on the remote computer.
if you want to execute wmi command with a local account of the remote computer, you must add lines in the script to connect first to the remote wmi system.
A good example is given at "Problem with semisyncronous WMI query" in KiXtart bulletinboard.
There is a block like
Code:
if $username and $computer<>'.'
; create locator object for connection to a remote computer
$objLocator = CreateObject('WbemScripting.SWbemLocator')
if @ERROR
exit @ERROR
endif
; create a (credentialed, if username/password provided) connection to a remote computer
$objWBEM=$objLocator.ConnectServer($computer,$namespace,$username,$password)
if @ERROR
exit @ERROR
endif
; set the impersonation level
$objWBEM.Security_.ImpersonationLevel = 3
if @ERROR
exit @ERROR
endif
endif
first, you create an object for WbemLocator
second, you connect to the remote computer (and here, you can use a local account of the remote computer)
third, you set impersonation level.
this is more complex than using
Code:
$Service = GetObject("winmgmts:\\+$sComputer+\root\cimv2")
_________________________
Christophe