Removing Policies
Removing Policies
Policies are removed using the Remove-EmdbPolicy cmdlet or the method Delete() of the Policy object. For both ways you first need to retrieve the Policy object and store it into a PowerShell variable in oder to use it with the cmdlet or to invoke the Delete()-method.
Examples:
Hint: The execution of these examples requires a connected PowerShell drive. |
The example below deletes the Policy assigning the Software Package "Microsoft Office 2010" to the Computer-Group "Default". At first, all Policy objects for the target must be retrieved. Then the result is filtered, so the only the Policy object in question remains in the pipeline and finally this is passed to the Remove-EmdbPolicy cmdlet. The switch-parameter -force ensures, that the Policy is forcibly deleted (meaning, existing Policy-Instances are deleted directly and are not marked for uninstall).
Get-EmdbPolicy "emdb:\rootDSE\Managed Users & Computers\solys.local\Default" | Where-Object {$_.AssignedObjectName -eq "Microsoft Office 2010"} | Remove-EmdbPolicy -force |
Retrieve the Policy that represents the assignment of the Software Package named "Adobe Reader 9.0" to the Computer Group named "Adobe Reader 9.0 systems" and store the result in the variable "$MyPolicy". Afterwards invoke the deletion method on that object:
$MyPolicy = Get-EmdbPolicy "emdb:\rootDSE\Managed Users & Computers\solys.local\Adobe Reader 9.0 systems" | Where-Object {$_.AssignedObjectName -eq "Adobe Reader 9.0"} $MyPolicy.Delete() |
Note that invoking the deletion method does not remove the Policy immediately, it is prepared for deinstallation only. You can force the deletion of the Policy without uninstalling the associated Software Package, if you supply the parameter $True to the method:
$MyPolicy = Get-EmdbPolicy "emdb:\rootDSE\Managed Users & Computers\solys.local\Adobe Reader 9.0 Rechner" | Where-Object {$_.AssignedObjectName -eq "Adobe Reader 9.0"} $MyPolicy.Delete($True) |
Hint: Note that deleting a Policy object implies that it is deleted for all objects in its Policy Target List. |