Friday, July 15, 2016

Deploy a Powershell Script using SCCM


Deploy a Powershell Script using SCCM This is the process to create a powershell script and deploy it to a site collection The first step is to open up operations manager and create a new package. This module can be found at Software Library-->Overview–>Operating Systems --> Packages







Enter a name and description for your module and click next, next next. Choose powershell for the program you are going to run.

Now that your package is created it needs to be edited. Right click the newly created package and choose edit.







The command line entry is the name of the script you are going to run. 
The start in folder is the path where the script is homed. This path needs to be accessible from the server you are deploying this to. After the package is deployed the remote machine will run this script from this location.




Now you need to create a new task sequence to trigger the package. Navigate to Software Library-->Overview–>Operating Systems --> Task Sequences








Create a custom task sequence, click next, name it and finish.
Now you are going to edit the task sequence. Right click the newly created task sequence and choose edit.  The first step is to choose the associated package. Browse to the package which was created in the first step.





Similarly to the package creation process you need to enter the script name. Additionally  it is necessary to specifying powershell being called with these flags.

powershell.exe -executionpolicy bypass -file scriptname.ps1





Click OK and finish.
Lastly you need to deploy this task sequence to a site collection. Once the server checks in it will deploy the package.
Right click the task sequence and choose deploy.
Click browse and navigate to the collection you want to deploy this to,





After you choose the collection set up the deployment schedule. These tasks can be set up to be run daily.






No comments:

Post a Comment