An
addition to Multi-NcCmdlets.psm1 - as detailed in the previous post. This one
deletes all 7-Mode snapshots from volumes transitioned from 7 to C, for every
connected Cluster. The process cycles through all connected controllers, cycles
through all operational data SVMs, cycles through all R/W and online volumes,
finds the 7-Mode snapshots and removes them. To run:
Multi-Delete7ModeSnapshots
The Code
Function
Multi-Delete7ModeSnapshots{
If( !(Verify-NcConnectedControllers) ){
RETURN }; Wr
$VsAttrs = Get-NcVserver -Template
$VsQuery = Get-NcVserver -Template
$VsQuery.VserverType = "data"
$VsQuery.OperationalState =
"running"
$VolAttrs = Get-NcVol -Template
$VolQuery = Get-NcVol -Template
Initialize-NcObjectProperty -Object $VolQuery
-Name VolumeIdAttributes
Initialize-NcObjectProperty -Object $VolQuery
-Name VolumeStateAttributes
$VolQuery.VolumeIdAttributes.Type = "rw"
$VolQuery.VolumeStateAttributes.State =
"online"
$SnapAttrs = Get-NcSnapshot -Template
$SnapAttrs.Is7ModeSnapshot = ""
$Global:CurrentNcController | Foreach {
[System.Array]$DataVservers =
(Get-NcVserver -Controller $_ -Query $VsQuery -Attributes $VsAttrs).VserverName
Foreach($SVM in $DataVservers){
[System.Array]$OnlineRwVolumes =
(Get-NcVol -Attributes $VolAttrs -Query $VolQuery -Controller $_
-VserverContext $SVM).Name
Foreach($Volume in $OnlineRwVolumes){
Wr ("Removing any 7-Mode snapshots
from " + $_.Name + ":" + $SVM + "\" + $Volume) YELLOW;
WR
Get-NcSnapshot -Volume $Volume
-Attributes $SnapAttrs -Controller $_ -Vserver $SVM | Where {
$_.Is7ModeSnapshot -eq $TRUE } | Format-Table Name,Is7ModeSnapshot -AutoSize
Get-NcSnapshot -Volume $Volume
-Attributes $SnapAttrs -Controller $_ -Vserver $SVM | Where {
$_.Is7ModeSnapshot -eq $TRUE } | Remove-NcSnapshot -Confirm:$FALSE
}
}
};Wr
}
Comments
Post a Comment