Hi Guys,
I use these Powershell scripts to remove datasources from Protection Group:
(Data are retained for recovery purpose when using "-KeepDiskData" parameter. If you don't use "-KeepDiskData", Replica and Recovery points will be deleted)
1- CleanUp your DPM Server - Delete All Protection Groups
Connect-DpmServer $env:COMPUTERNAME
$PgList = @()
$PgList = Get-ProtectionGroup -DPMServerName $env:computername
foreach($Pg in $PgList){
write-host ""
Write-host "# ProtectionGroup Name " -ForegroundColor red -Nonewline
Write-host $Pg.FriendlyName -ForegroundColor green
$mpg = Get-ModifiableProtectionGroup $Pg
$dsList = @()
$dsList = Get-DataSource -ProtectionGroup $Pg
foreach($ds in $dsList){
write-host ("Remove data source ",$ds.Name)
Remove-ChildDataSource -ProtectionGroup $mpg -ChildDataSource $ds -keepDiskData
}
Set-ProtectionGroup $mpg
}
Disconnect-DpmServer $env:COMPUTERNAME
2- Delete a Protection Goup
Connect-DpmServer $env:COMPUTERNAME
$StringSearch="YourStringSearch"
$PgList = @()
$pgList = Get-ProtectionGroup -DPMServerName $env:computername
where {($_.friendlyname) -match $StringSearch}
foreach($Pg in $PgList){
write-host ""
Write-host "# ProtectionGroup Name " -ForegroundColor red -Nonewline
Write-host $Pg.FriendlyName -ForegroundColor green
$mpg = Get-ModifiableProtectionGroup $Pg
$dsList = @()
$dsList = Get-DataSource -ProtectionGroup $Pg
foreach($ds in $dsList){
write-host ("Remove data source ",$ds.Name)
Remove-ChildDataSource -ProtectionGroup $mpg -ChildDataSource $ds -keepDiskData
}
Set-ProtectionGroup $mpg
}
Disconnect-DpmServer $env:COMPUTERNAME
Feel free to customize/use it.
Thanks! It's rather infuriating that Microsoft doesn't offer a native way to do this. The GUI option is incredibly slow.
ReplyDelete