This script will enable on the wire compression for a given protection group. This script will check if the DPM PowerShell SnapIn is loaded and load if not which means this script can be run in PowerShell as well as the DPM Command Shell.
To run the script: ./EnableCompression.ps1 -DPMServerName <DPMServerName> -ProtectionGroup <ProtectionGroup>
For usage instructions: ./EnableCompression.ps1 -help
Here is the PowerShell script for you to copy or you can download the full PS1 file at the bottom of this page.
----------Script Start----------
#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
## Author: David Allen
# Date: 24/08/09
#
# http://www.scdpmonline.org
#
# Comment: This script will enable on the wire
# compression for a given DPM protection group.
#
# Instructions for use: ./EnableCompression.ps1 -help
#
#'''''''''''''''''''''''''''''''''''''''''''''''''''''''''
param ([string] $DPMServerName, [string] $ProtectionGroup)
function Usage()
{
write-host
write-host "Usage::"
write-host "EnableCompression.ps1 -DPMServerName [DPMServername] -ProtectionGroup [ProtectionGroupName]"
write-host
write-host "Run 'EnableCompression.ps1 -detailed' for detailed help"
write-host
}
if(("-?","-help") -contains $args[0])
{
Usage
exit 0
}
if(("-detailed") -contains $args[0])
{
write-host
write-host "Detailed Help : Use this script to enable on-the-wire compression on a given protection group."
write-host
exit 0
}
#Check status of DPM SnapIn and load as necessary
$SnapIn = "Microsoft.DataProtectionManager.PowerShell"
if (get-PSSnapIn $SnapIn -ea "silentlycontinue")
{
write-host "PSSnapIn $snapin is loaded"
}
elseif (get-PSSnapIn $SnapIn -registered -ea "silentlycontinue")
{
write-host "PSSnapIn $SnapIn is registered but not loaded"
Write-host "Loading PSSnapIn $SnapIn"
Add-PSSnapIn $SnapIn
}
else
{
write-host "PSSnapIn $SnapIn not found" -foregroundcolor Red
}
#Prompt if the name of the DPM server has not been passed
if(!$DPMServerName)
{
$DPMServerName = read-host "DPMServerName:"
}
#Connect to DPM server
$DpmServer = Connect-DPMServer $DPMServerName
if (!$DpmServer)
{
write-Error "Unable to connect to DPM server::$DPMServerName"
exit 1
}
#Prompt if the name of the protection group has not been passed
if(!$ProtectionGroup)
{
$ProtectionGroup = read-host "ProtectionGroup:"
}
write-host "Enabling compression on protection group $ProtectionGroup"
#Returns a list of all the protection groups on the DPM server and confirms there is at least one
$pgl = @(Get-ProtectionGroup -DPMServerName $DPMServerName)
if($pgl.count -lt 1)
{
write-Error "No protection groups found on DPM server"
exit 1
}
#Get protection group
$pg = $pgl | where {$_.FriendlyName -eq $ProtectionGroup}
if(!$pg)
{
Write-Error "Failed to get protection group"
exit 1
}
#Get modifiable protection group
$mpg = Get-ModifiableProtectionGroup -ProtectionGroup $pg
if(!$mpg)
{
Write-Error "Failed to get modifiable protection group"
exit 1
}
#Enable Compression
set-performanceoptimization -protectiongroup $mpg -enablecompression
#Set the protection group to apply the change
Set-ProtectionGroup -ProtectionGroup $mpg
Write-Host "Compression enabled for portection group $ProtectionGroup"
#Disconnect from the DPM Server
Disconnect-Dpmserver
---------- Script End ----------
Attachment: EnableCompression.ps1