Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Monday, August 27, 2012 2:47 PM
Hello
I'm using a powershell script push by a GPO.
I want to be able to remove all network printers at logon and then remapped printers based on IP address.
To remove printer i'm using the following command : Get-WMIObject Win32_Printer | where{$_.Network -eq 'true'} | foreach{$_.delete()}
It's working perfectly when i'm running the command in a user session but for some reason, it doesn't seem to work, it looks like Windows is not ready or something...
Is there a way to run this command in a logon script?
Thanks
All replies (6)
Monday, August 27, 2012 4:00 PM ✅Answered | 1 vote
Use Scheduled Task
http://www.grouppolicy.biz/2010/01/how-to-schedule-a-delayed-start-logon-script-with-group-policy/
Or more simple
User Configuration\Policies\Windows Settings\Scripts Logon (PowerShell Scripts tab)
http://technet.microsoft.com/sv-se/library/dd367856(v=ws.10).aspx
Сазонов Илья http://isazonov.wordpress.com/
Thursday, August 30, 2012 8:27 AM ✅Answered
Hi,
We could use Group Policy to deploy logon script, but if you use logon script to map printers and also want to use logon script to remove printers, there may be issues, if those printers are already mapped, and then we could use Logon script to remove them.
Remove local / network printers possible with GPP ?
Remove Printer Script windows 7
Hope this helps.
Regards,
Yan Li
Yan Li
TechNet Community Support
Monday, August 27, 2012 3:02 PM
I assume that there are mapped printers created when the user logs on. If your script tries to remove them before they are created, it won't work. Try putting a pause at the start of the script of about 1 second.
Start-Sleep 1
Grant Ward, a.k.a. Bigteddy
Monday, August 27, 2012 3:03 PM
Run script by GPP with Run in logged-on user's security context option on
Сазонов Илья http://isazonov.wordpress.com/
Monday, August 27, 2012 3:27 PM
Yes the printers are already mapped. Well here's the story, printers are mapped in the login script.
For some reason, the default printer changes randomly, so what i'm trying to do is, select default printer name in a variable, remove all printer from the session, then remap printers and re-set default printer with the variable i took at the begining.
It's working fine, but for some reason, it will not run the command : Get-WMIObject Win32_Printer | where{$_.Network -eq 'true'} | foreach{$_.delete()} in the script...
Monday, August 27, 2012 3:28 PM
Is there a way to run a ps1 file in GGP?!