File tree Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Expand file tree Collapse file tree 1 file changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,9 @@ foreach ($vc in $vcenters) {
6565 Remove-Folder - Server $vcenter - Folder $ ($folder.Entity ) - DeletePermanently - confirm:$false
6666 }
6767
68+ # Clean up CNS volumes
69+ # TODO: Add cleanup for CNS here. This will be done in later PR.
70+
6871 # Clean up storage policy. Must be done after all other object cleanup except tag/tagCategory
6972 $storagePolicies = Get-SpbmStoragePolicy - Server $vcenter - Tag $tag
7073
@@ -80,8 +83,16 @@ foreach ($vc in $vcenters) {
8083 $clusterInventory = @ (Get-Inventory - Server $vcenter - Name " $ ( $clusterId ) *" - ErrorAction Continue )
8184
8285 if ($clusterInventory.Count -eq 0 ) {
86+ # Remove policy from all configurations that still may exist
87+ $entityConfig = Get-SpbmEntityConfiguration - StoragePolicy $policy
88+ if ($null -ne $entityConfig -and $entityConfig -ne $null ) {
89+ Write-Host " Unsetting storage policy for " $entityConfig
90+ Set-SpbmEntityConfiguration $entityConfig - StoragePolicy $null
91+ }
92+
93+ # Now we can delete the policy
8394 Write-Host " Removing policy: $ ( $policy.Name ) "
84- $policy | Remove-SpbmStoragePolicy - Server $vcenter - Confirm:$false
95+ $policy | Remove-SpbmStoragePolicy - Server $vcenter - Confirm:$false - ErrorAction Continue
8596 }
8697 else {
8798 Write-Host " not deleting: $ ( $clusterInventory ) "
You can’t perform that action at this time.
0 commit comments