‎03-25-2022 08:20 AM
powershell.exe -executionpolicy bypass -file "{PackageShare}\NO.SCR\Add-And-Remove-Printers.ps1"
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!'
‎03-28-2022 10:12 PM
‎03-25-2022 09:57 AM
New-Item -Path "C:\Temp" -Name "Print-Completed.txt" -ItemType "file" -Value "The command was a success."
‎03-28-2022 07:09 AM
Julian B wrote:
Thank you for answering. I have checked the path and everything is correct. The script runs on the user's computers, but the only thing that is working in this line:New-Item -Path "C:\Temp" -Name "Print-Completed.txt" -ItemType "file" -Value "The command was a success."
I checked the user's temp folder and the file is created, but the printers are not added or removed.
If I run the PS script locally on my machine everything is working as intended. I don't understand what is going on here.
‎03-25-2022 09:00 AM
Experience Lansweeper with your own data. Sign up now for a 14-day free trial.
Try Now