Add printer powershell through KACE
I have the following powershell script:
Invoke-Expression 'rundll32 printui.dll,PrintUIEntry /in /q /n "\\printserver\newprinter"'
Invoke-Expression 'rundll32 printui.dll,PrintUIEntry /dn /q /n "\\oldserver\oldprinter"'
It runs without any issue invoking it from the local machine.
I have set the KACE to use an online shell script, loaded the powershell script as a dependancy, and use the following command:
"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe" -nologo -executionpolicy bypass -WindowStyle hidden -noprofile -file ".\printer.ps1"
If I use the logged in user, I get a failure with "Error 193 while executing script". If I use all logged in users, I get a success, explorer.exe crashes, and printers no longer work until the system is restarted. Has anyone successfully used powershell from the KACE to implement a printer transition?
Use the printer management vbs scripts that are on the system: http://technet.microsoft.com/en-us/library/cc725868%28v=ws.10%29.aspx Make sure to change the script extension to .bat.
Ok, thank you both for your help. I have a theory as to why I am having so much difficulty.
When I create an online script in the KACE, is the KACE downloading the dependencies and running the script against the machine, or is the KACE downloading the script and the dependencies and running the script on the machine?
I have a feeling what is happening is that since I was not changing the main script extension from the default .sh, I have been trying to run the container script as a bash file. This would normally generate an error from the KACE, but since I happen to use gVim as an editor, gVim is running the container .sh script, and the KACE doesn't care whether gVim returns an error trying to run the dependency, so it returns the script deployment as successful regardless of whether the dependency was ever run.
Does this sound plausible as the tragedy that is occurring here?