-
Notifications
You must be signed in to change notification settings - Fork 4
Configuration
Configuration of PowerShell Protect is done using XML. You can create the XML file in the following locations.
You can use the configuration cmdlets to get, set and test your Protect configurations.
To set a configuration for the local machine, you can use Set-PSPConfiguration
. You will need to provide a path to a Protect configuration file and then the destination of the configuration.
The below will install the configuration file into the file system location.
Set-PSPConfiguration -ConfigurationFilePath .\config.xml -FileSystem
The below will install the configuration file into the registry.
Set-PSPConfiguration -ConfigurationFilePath .\config.xml -Registry
You can also pass a Configuration object created with New-PSPConfiguration
to Set-PSPConfiguration
.
$Config = New-PSPConfiguration #options
Set-PSPConfiguration -Configuration $Config -Registry
To return the current Protect configuration, use Get-PSPConfiguration
. You will receive a configuration object or null if no configuration is installed.
Get-PSPConfiguration
Rules Actions
----- -------
{Web Request} {File, Block}
To test a configuration file before installing it, you can use Test-PSPConfiguration
. This cmdlet will use the specified configuration file and evaluate the provided script block. The Test-PSPConfiguration
cmdlet will return either Ok
if the script will not be blocked and AdminBlock
if the script will be blocked. Other actions, such as TCP or HTTP, will also be executed.
Test-PSPConfiguration -ConfigurationPath ".\config.xml" -ScriptBlock { Invoke-WebRequest }
AdminBlock
This cmdlet is used to save configuration files to disk. Specify the Configuration object and path.
$Config = New-PSPConfiguration #options
Save-PSPConfiguration -Configuration $Config -Path .\myconfig.xml
You can create an XML file in %ProgramData%\PowerShellProtect\config.xml
. You will need to set the proper permissions so the XML file is readonly. Any changes made to the XML file will automatically be reloaded by PowerShell Protect.
You can create an XML document and store it in the registry key HKLM\Software\Ironman Software\PowerShell Protect
in the value Configuration
.
You can also specify the path to an XML document by creating the registry key HKLM\Software\Ironman Software\PowerShell Protect
and setting the value ConfigurationFile
. This needs to be the full path to the file. Environment variables will be expanded.
Configuration methods are loaded by precedence. Options higher in the precedence will be checked first. If a configuration file exists in that location, it will be loaded first and the subsequent locations will not be loaded.
- Registry Configuration File
- Registry Configuration Path
- ProgramData File