Expired certificate remediation script
- 1 Remediation powershell script
- 2 Intune
- 3 SCCM
- 3.1.1 Properties for Run PowerShell Script
- 3.1.1.1 Package
- 3.1.1.2 Script name
- 3.1.1.3 Enter a PowerShell script
- 3.1.1.4 Parameters
- 3.1.1.5 PowerShell execution policy
- 3.1.1.6 Start in
- 3.1.1.7 Time-out (minutes)
- 3.1.1.8 Run this step as the following account (Account)
- 3.1.1 Properties for Run PowerShell Script
- 3.2 Options for Run PowerShell Script
- 4 ManageEngine
Remediation powershell script
Intune
For more information how to create intune package see Runbook: Deploying agent using Microsoft Intune
Content:
install.bat
PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& {Start-Process PowerShell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -File ""%~dp0remediate.ps1""' -Verb RunAs}"
SCCM
Create or Edit an Existing Task Sequence
Use the following steps to modify an existing task sequence.
In the Configuration Manager console, go to the Software Library workspace, expand Operating Systems, and then select the Task Sequences node.
In the Task Sequence list, select the task sequence that you want to edit. Select Edit to modify.
To add this step in the task sequence editor, select Add, select General and select Run PowerShell Script.
This step can be run in the full OS or Windows PE. To run PowerShell Script step in Windows PE, enable PowerShell in the boot image. Enable the WinPE-PowerShell component from the Optional Components tab in the properties for the boot image.
Properties for Run PowerShell Script
On the Properties tab for Run PowerShell Script step, You can configure the following settings –
Package
Script name
Enter a PowerShell Script
Parameters
PowerShell execution policy
Start in
Time-out (minutes)
Run this step as the following account (Account)
Add Run PowerShell Script Step to SCCM Task Sequence 8
Package
Select this option to specify the Configuration Manager package that contains the necessary files for execution. It can contain multiple PowerShell scripts.
Script name
Specifies the name of the PowerShell script to run. For Example – FileName.ps1
Add Run PowerShell Script Step to SCCM Task Sequence 9
Enter a PowerShell script
In this step, you can enter the PowerShell code directly. This feature lets you run PowerShell commands during a task sequence without distributing a package. If needed, you can directly do the changes and perform testing without looking into the package creation process and distribution.
When you add or edit a script, the PowerShell script window provides the following actions –
Edit the script directly.
Click Open an existing script from file
Browse to an existing approved script in Configuration Manager
Add Run PowerShell Script Step to SCCM Task Sequence 10
Parameters
If you use a script in a package, you can specify the parameters passed to the PowerShell script. These parameters are the same as the PowerShell script parameters on the command line.
PowerShell execution policy
Determine which PowerShell scripts you allow running on the computer. You can choose one of the following execution policies –
AllSigned: Only run scripts signed by a trusted publisher.
Undefined: Don’t define any execution policy.
Bypass: Load all configuration files and run all scripts. If you download an unsigned script from the internet, Windows PowerShell doesn’t prompt for permission before running the script.
Start in
This field is optional. You can specify the executable folder for the program, up to 127 characters. This folder can be an absolute path on the destination computer or a path relative to the distribution point folder that contains the package.
Time-out (minutes)
This option is disabled by default. Specifies a value that represents how long Configuration Manager allows the command line to run. This value can be from one minute to 999 minutes. The default value is 15 minutes.
Run this step as the following account (Account)
Here you can specify the local user or domain account to run the command line. The command line runs with the permissions of the specified account. Select Set to specify the account.
Options for Run PowerShell Script
On the Run PowerShell Script step, Options tab. Here you can configure the additional settings of this task sequence step –
Continue on error – When you select Continue on error on the Options tab of this step, the task sequence continues when a PowerShell Script fails to execute. When you don’t enable this option, the task sequence fails and will not execute the remaining steps.
Success codes – Include other exit codes from the script that the step should evaluate as success.
Add Run PowerShell Script Step to SCCM Task Sequence 11
Once you are done, click Apply and OK to save the changes. Close the task sequence editor, and the task sequence is ready for deployment.
ManageEngine
To add a Powershell Script as a software package, follow the steps mentioned below:
Navigate to Software Deployment >> Packages and click on "Add Package >> Windows".
Enter the name of the package as desired, and select "EXE / APPX / MSIEXEC / MSU"
Select the license type as "Non Commercial".
For uploading the script in "Locate Installable", there are two ways:
From Shared Folder: If you have the script in a shared folder, you can choose this option and upload the .ps1 file.
From Local Computer: If the script is on the computer via which you're accessing the console, choose this option and upload the .ps1 file.
Once the file has been uploaded, enter the following script under "Installation Command with Switches/Arguments":
"< powershell.exe -NoProfile -ExecutionPolicy Bypass -File (name-of-the-script-file) > "Click on "Add Package"
You have successfully created a package for the powershell script. You can now deploy it to the required computers in your network.
Related content
Classified as Getvisibility - Partner/Customer Confidential