Nov 04 2021 02:04 PM - edited Nov 04 2021 02:10 PM
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?
Nov 04 2021 10:00 PM
What is the command line you are using in your deployment? Are you using Start /wait to ensure the command stays open while the script runs?
James
Nov 05 2021 08:00 AM
Thanks for the reply. I am just starting out with working in PowerShell.
This is the command line:
powershell.exe -executionpolicy bypass -file ".\Filename.ps1"
Where would the Start /wait go.
Nov 05 2021 04:56 PM
Nov 08 2021 09:31 AM
Thanks again. So it would look something like this?
@start /wait powershell.exe -executionpolicy bypass -file ".\File.ps1"
Nov 18 2021 02:57 AM