|
Hi Team
I am trying create a login script that will add printer queues for a client PC when the user logs in. I have used the UDF PrinterList() from Allen Powell which works well when I am logged in as a user with permissions to interrogate the print server. However when I run as a domain user the code falls over on
$Service = GetObject("winmgmts:\\" + $remotepc + "\root\cimv2")
I guess I need to execute the code as a priviledged user account on the print server. I have found the following code on MSDN
$wbemImpersonationLevelImpersonate = 3 $wbemAuthenticationLevelPktPrivacy = 6
$objLocator = CreateObject("WbemScripting.SWbemLocator") $objService = objLocator.ConnectServer("TargetComputer", "root\cimv2", "UserName", "Password") objService.Security_.ImpersonationLevel = $wbemImpersonationLevelImpersonate objservices.Security_.AuthenticationLevel = $wbemAuthenticationLevelPktPrivacy
This suggests that I can connect as another user but the code fails after objService.Security_.ImpersonationLevel = $wbemImpersonationLevelImpersonate
Am I barking up the wrong tree ? is there a better way ?
I would also need to know the minimum priviledges required to execute
$Printers=$service.execquery ('select * from Win32_Printer')
TIA
Mark
|