How to remove a custodian relationship using PowerShell or Orchestrator
Best Answer
-
Tomi_Kaartama Customer IT Monkey ✭This is the code I use when I want to remove software asset authorization. I would imagine you could get this to work if you just replace the RelationShipID with the custodian relationshipID.$ComputerCI = 'got-crl7wz1.corpnet.liox.org'$CI = Get-SCSMObject (Get-SCSMClass System.ConfigItem$) -Filter "Name -eq $ComputerCI"$SW = Get-SCSMObject (Get-SCSMClass Cireson.AssetManagement.SoftwareAsset$)$RelatedHW = Get-SCSMRelationshipObject -BySource $SW | Select-Object -Property TargetObject,RelationshipIDforeach ($HW in $RelatedHW) {If ($HW.TargetObject.DisplayName -eq $CI.DisplayName) {If ($HW.RelationshipID -eq '42d94b36-4ea1-a110-6cf8-b0dae1cc2295') {$RelAuthorized = Get-SCSMRelationshipClass Cireson.AssetManagement.SoftwareAssetHasAuthorisedComputer$Get-SCSMRelationshipObject -Relationship $RelatedHW | ?{$_.SourceObject -eq $HW} | ?{$_.TargetObject -eq $CI} | Remove-SCSMRelationshipObject}}}5
Answers