Forum Discussion

John Andrews's avatar
John Andrews
Copper Contributor
Nov 04, 2021

Run Script from SCCM

I am a novice at PowerShell. I have a request to run a script from SCCM to install a list of printer drivers. Script is as follows...

 

# Ricoh Universal Print Driver
Get-ChildItem "\\server\d$\Print_Drivers\Ricoh\Universal Print Driver ver4_27\disk1" -Recurse -Filter "*.inf" |

ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install }
# Ricoh SP3410dn Print Driver
Get-ChildItem "\\server\d$\Print_Drivers\Ricoh\SP 3410DN\PCL6\DISK1" -Recurse -Filter "*.inf" |
ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install }
# Ricoh SP3510dn Print Driver
Get-ChildItem "\\server\d$\Print_Drivers\Ricoh\SP 3510DN\PCL6\DISK1" -Recurse -Filter "*.inf" |
ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install }
# Ricoh SPC232dn Print Driver
Get-ChildItem "\\server\d$\Print_Drivers\Ricoh\SP C232DN\PCL6\DISK1" -Recurse -Filter "*.inf" |
ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install }
# HP T1300 Print Driver
Get-ChildItem "\\server\d$\Print_Drivers\HP\T1300 PS Server 2016\win_x64_ps3_drv\win_x64_ps3_drv" -Recurse -Filter "*.inf" |
ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install }
# Zebra ZDesigner GX420t Print Driver
Get-ChildItem "\\server\d$\Print_Drivers\Other\Zebra\ZD5-1-16-7110\ZBRN" -Recurse -Filter "*.inf" |
ForEach-Object { PNPUtil.exe /add-driver $_.FullName /install }

 

I can run this script locally on a machine & it runs fine, takes about 90 seconds to complete.

 

When I create an application for it in SCCM & deploy it, its like it doesn't have time to complete the installs before PowerShell shuts down. Then the app shows as failed in Software Center.

 

How do I make it wait to finish running the script before closing out PowerShell?

Resources