/build/static/layout/Breadcrumb_cap_w.png

"'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
  • I believe you are missing the execution policy bypass switch..

    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 5 years ago
    • I take back my previous post, this worked a charm!

      We don't have Bypass on as we sign our scripts. - dsalt 5 years ago
      • Can you post an answer summary, please? - chucksteel 5 years ago
  • I followed the steps for "Method 2" in the link provided by Channeler (below) and it worked perfectly. The only thing it seemed to do was ignore the read-host prompts that I had put in for testing but this didn't matter in this case.

    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 5 years ago

Answers (1)

Posted by: chucksteel 5 years ago
Red Belt
1
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 5 years ago
    • Yes, instead of calling c:\windows\system32\pnputil.exe you call c:\windows\sysnative\pnputil.exe - chucksteel 5 years ago
      • Thanks for the advise, looks like I've lucked out on that one, it doesn't find the path. - dsalt 5 years ago
 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ