Removing Policy-Instances

Policy-Instances can be removed only under certain circumstances. As a rule of thumb, these conditions are met, if the "Delete"-command is shown in the context-menu of a Policy-Instance in the DSMC. A more detailed description of when Policy-Instances can be deleted and when they cant't can be found in the chapter "Changed Requirements for Deleting Policy Instances" in the release notes of the DSM 7.0 release.


In order to delete Policy-Instances, the cmdlet Remove-EmdbPolicyInstance or the Delete()-method of Policy-Instance objects is used. For both ways you first have to retrieve the Policy-Instance in question, store the object into a variable an use this one with the cmdlet or invoke the method.


Examples:


Hint: The execution of these examples requires a connected PowerShell drive.


In the example below, the Policy-Instance for the Software Package "Microsoft Office 2010" of the Computer XP01 is retrieved and then passed to the Remove-EmdbPolicyInstance cmdlet:


Get-EmdbPolicyInstance "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP01" | Where-Object {$_.AssignedObjectName -eq "Microsoft Office 2010"} | Remove-EmdbPolicyInstance


The same result can be achieved using the Delete()-method:


$MyPolicyInstance = Get-EmdbPolicyInstance "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP01" | Where-Object {$_.AssignedObjectName -eq "Microsoft Office 2010"} 

$MyPolicyInstance.Delete()


Note: If you are trying to remove a Policy-Instance that cannot be deleted, an error is thrown.