Combining PowerShell Scripts into Single PS1
Posted on 2014-02-03
Hey Guys -
Got a newb, PowerShell 101 question for you...
I have a string that I use to advertise advertisements to collections in SCCM 2012. One of the strings is below:
Start-CMSoftwareUpdateDeployment -SoftwareUpdateGroupName "Workstation Related - Feb 2014 Deployment" -CollectionName "Workstation Patch Management - Window #8 - 3rd Wednesday - Auto Restart" -DeploymentName "Workstation Patch Management - Window #8 - 3rd Wednesday - Auto Restart Feb 2014" -DeploymentType Required -VerbosityLevel OnlySuccessAndErrorMessages -TimeBasedOn UTC -DeploymentAvailableDay 2014/2/19 -DeploymentAvailableTime 6:00 -DeploymentExpireDay 2014/2/19 -DeploymentExpireTime 6:00 -UserNotification DisplaySoftwareCenterOnly -SoftwareInstallation $False -AllowRestart $False -RestartServer $False -RestartWorkstation $False -ProtectedType NoInstall -UnprotectedType NoInstall
I have duplicated it many times and changed variables so that each line sets a new, different advertisement. I tried putting all of these lines into a text file (using notePad++) with each string on a line then saved it as a PS1. When I ran it in PowerShell, though, it failed. Once it ran, but froze half way through. If I copy / paste / run each line separately, it works great.
How do I combine these to work properly in a single script? Thanks