"'pnputil.exe' is not recognized as the name of a cmdlet" only through Kace
Kind of as above really. I have a Powershell script using pnputil.exe to add some printer drivers and it works perfectly ran locally no matter how I call the script and works if I just run that one line. The moment I run a bat file in KACE to call it, it says it can't recognize it. The BAT file is running as system.
I was hoping to use the add-windowsdriver command but everytime I try and get it to work with that it prompts me for the path but I shall probably have antoher crack at it as this is failing miserably
I've tried uploading the exe, adding a CD command before hand, putting the full path, using invoke-command or just pnputil.exe running the script as a dependency and running it from a remote location.
BAT file calling PS
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -noexit -Command "Start-Process Powershell -Verb RunAs" ".\tx3000.ps1"
Actual Powershell
invoke-command {pnputil.exe /add-driver "\\prometheus\it_Tools\Drivers\Canon\Canon TX3000\p68n-win-tx_2000_tx_3000_tx_4000-1_01-ea22_5\Driver\TX-40006.INF" /install}
Read-Host -Prompt "Add-driver"
Add-PrinterPort -Name "Alan" -PrinterHostAddress "10.140.131.3"
Read-Host -Prompt "Add-Port"
Add-PrinterDriver -Name "Canon TX-3000"
Read-Host -Prompt "Add-PrintDriver"
Add-Printer -name "Alan" -DriverName "Canon TX-3000" -PortName "Alan"
Read-Host -Prompt "Add-Printer"
2 Comments
[ + ] Show comments
Answers (1)
Please log in to answer
Posted by:
chucksteel
6 years ago
First issue is that you are referencing a network path and in most cases the SYSTEM account on the local machine won't have access to it. You can instead upload the INF as a dependency.
The only other possibility is that pnputil.exe isn't available in the 32bit context where the AMPAgent runs. I have only seen that with the manage-bde executable for managing BitLocker.
Comments:
-
Unfortunately it doesn't look like it was the location, I tried adding it as a dependency as you suggested but the same error, I don't think it's even getting that far.
Did you find a solution for the 32bit issue at all? - dsalt 6 years ago-
Yes, instead of calling c:\windows\system32\pnputil.exe you call c:\windows\sysnative\pnputil.exe - chucksteel 6 years ago
-
Thanks for the advise, looks like I've lucked out on that one, it doesn't find the path. - dsalt 6 years ago
anyway
check this:
https://support.quest.com/kace-systems-management-appliance/kb/138389/powershell-script-from-the-k1000
Tried method number 2, that is the one I use, works 99% of the time - Channeler 6 years ago
We don't have Bypass on as we sign our scripts. - dsalt 6 years ago
I also removed the execution policy setting as it was irrelevant.
https://support.quest.com/kace-systems-management-appliance/kb/138389/powershell-script-from-the-k1000 - dsalt 6 years ago