/build/static/layout/Breadcrumb_cap_w.png

Scripting Question


"'pnputil.exe' is not recognized as the name of a cmdlet" only through Kace

07/19/2018 3784 views
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

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
    • This content is currently hidden from public view.
      Reason: Removed by member request For more information, visit our FAQ's.
    • I take back my previous post, this worked a charm!

      We don't have Bypass on as we sign our scripts.
      • Can you post an answer summary, please?
  • 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

All Answers

0
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.

Answered 07/19/2018 by: chucksteel
Red Belt

  • 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?
    • Yes, instead of calling c:\windows\system32\pnputil.exe you call c:\windows\sysnative\pnputil.exe
      • Thanks for the advise, looks like I've lucked out on that one, it doesn't find the path.
  • This content is currently hidden from public view.
    Reason: Member has been banned from the site For more information, visit our FAQ's.
 
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