$AllCohesityProtectionGroups = Get-CohesityProtectionJob | Where-Object Environment -eq kVMware | sort-object Name $AllCohesityVMwareVM = Get-CohesityVMwareVM $toDisable=@() ForEach($ProtectionJob in $AllCohesityProtectionGroups){ $IncludeTags = $ProtectionJob.vmTagIds[0][0] If($ProtectionJob.excludeVmTagIds[0][0]){ $ExcludeTags = $ProtectionJob.excludeVmTagIds[0][0] } $IncludeVMs = $AllCohesityVMwareVM | where-object {$_.VmWareProtectionSource.TagAttributes.Id -eq $IncludeTags} | Sort-object Name If($ProtectionJob.excludeVmTagIds[0][0]){ $ExcludeVMs = $AllCohesityVMwareVM | where-object {$_.VmWareProtectionSource.TagAttributes.Id -eq $IncludeTags -and $_.VmWareProtectionSource.TagAttributes.Id -eq $ExcludeTags} | Sort-object Name } Else{ $ExcludeVMs = $null } $VMsToBackup = $IncludeVMs | where-object {$ExcludeVMs -notcontains $_} If(@($VMsToBackup).count -ge 1){ # enable protection job #$ProtectionJob.isPaused = $False #$ProtectionJob | Set-CohesityProtectionJob -Confirm:$false } Else{ # disable protection job #$ProtectionJob.isPaused = $True #$ProtectionJob | Set-CohesityProtectionJob -Confirm:$false $toDisable += $ProtectionJob } } <# "tagAttributes": [ { "gcpTagType": null, "id": 8334, "name": "Reserved", "uuid": "urn:vmomi:InventoryServiceTag:7ec35aab-9234-4324-93c3-695e5664ed74:GLOBAL" }, { "gcpTagType": null, "id": 3407, "name": "Shared-PowerSchool", "uuid": "urn:vmomi:InventoryServiceTag:996627f1-ee30-4d92-8249-b1aa71c63d75:GLOBAL" }, { "gcpTagType": null, "id": 7065, "name": "Windows Server 2012 R2 Standard (64-Bit)", "uuid": "urn:vmomi:InventoryServiceTag:89e77b90-2876-476d-a346-2c9da6583ce9:GLOBAL" }, { "gcpTagType": null, "id": 3223, "name": "ABR", "uuid": "urn:vmomi:InventoryServiceTag:31bda67f-a610-460c-bd7c-75cc1adeb4c6:GLOBAL" }, { "gcpTagType": null, "id": 3205, "name": "4", "uuid": "urn:vmomi:InventoryServiceTag:3fd9b786-5d50-42b1-912e-95b9f0262891:GLOBAL" }, { "gcpTagType": null, "id": 3225, "name": "Production", "uuid": "urn:vmomi:InventoryServiceTag:3d04149e-c1aa-4f46-a7f5-f0cfcb1b4414:GLOBAL" }, { "gcpTagType": null, "id": 7108, "name": "No Licensing Restrictions", "uuid": "urn:vmomi:InventoryServiceTag:049ee6ff-5205-4b2c-bc20-a0c44e2eb05c:GLOBAL" } #>