Hi! I have some issues when deploying my PowerShell script. It works perfectly when I run it locally on my machine, but when I deploy it, it does not work. All my other PS scripts works, so maybe there is something that I have overlooked? I want to delete some of the printers that the users have, and add some new + setting it as default. I hope someone can help me with this one.
I'm deploying it with the command:
powershell.exe -executionpolicy bypass -file "{PackageShare}\NO.SCR\Add-And-Remove-Printers.ps1"
Here is the PS script:
Get-Printer
add-printer -ConnectionName "\\APP01\SafeQ-Color"
add-printer -ConnectionName "\\APP01\SafeQ-BW"
(New-Object -ComObject WScript.Network).SetDefaultPrinter('\\APP01\SafeQ-BW')
(New-Object -ComObject WScript.Network).RemovePrinterConnection("\\APP01\Safecom_Black")
(New-Object -ComObject WScript.Network).RemovePrinterConnection("\\APP01\Safecom_Color")
Remove-Printer -Name "\\APP01\Safecom_Black"
Remove-Printer -Name "\\APP01\Safecom_Color"
Remove-Printer -Name "\\APP01\osl-03-m"
Remove-Printer -Name "\\APP01\osl-04-m"
Remove-Printer -Name "\\APP01\osl-05-m"
Remove-Printer -Name "\\APP01\osl-06-m"
Remove-Printer -Name "\\APP01\osl-07-m"
New-Item -Path "C:\Temp" -Name "Print-Completed.txt" -ItemType "file" -Value "The command was a success."
Write-Host 'Completed!'
I'm open to suggestions if you know a better way to do this.