Getting Started
Getting started with PowerShell Protect.
PowerShell Protect can be installed from the PowerShell Gallery.
1
Install-Module PowerShellProtect
Copied!
To install the AMSI provider that is used to audit and block scripts, you will need to run the following command.
This command needs to be run as administrator.
1
Install-PowerShellProtect
2
$Configuration = New-PSPConfiguration
3
Set-PSPConfiguration -Configuration $Configuration -FileSystem
Copied!
Once installed, the Default Rules will be enabled. You can also enable additional rules using the PowerShell Protect configuration cmdlets.
For example, this configuration will block and audit any script that contains a command with webrequest in the name.
1
$Condition = New-PSPCondition -Property "command" -contains -Value "webrequest"
2
$BlockAction = New-PSPAction -Block
3
$FileAction = New-PSPAction -File -Format "{applicationName},{rule}" -Path "%temp%\audit.csv" -Name 'File'
4
$Rule = New-PSPRule -Name "Web Request" -Condition $Condition -Action @($BlockAction, $FileAction)
5
6
$Configuration = New-PSPConfiguration -Rule $Rule
7
Set-PSPConfiguration -Configuration $Configuration -FileSystem
Copied!
Last modified 21d ago
Copy link