Removing Computers

Removes the specified Computer object(s).


Examples:


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


Remove the Computer "XP21" from the context "solys.local\Chicago\ITService\Workstations":


Remove-EmdbComputer "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP21"


Remove the Computer "XP21" from the current context:


Cd "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations"

Remove-EmdbComputer "XP21"


As an alternative method, the following shows the removing of the Computer "XP21" from the context "solys.local\Chicago\ITService\Workstations" using the Delete()-method:


$MyComputer = Get-EmdbComputer "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP21"

$MyComputer.Delete()


Remove the Computer "XP22" from the context "solys.local\Chicago\ITService\Workstations" using the cmdlet Remove-Item:


Remove-Item "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP22"


Hint: Alternatively the alias DEL can be used to remove Computer objects.


Starting with PSX 3.1 there was a new option implemented when deleting Computer objects. When specifying the SingleItemExpected-switch it is expected, that none or exactly one object is affected. If the command would delete more than one object, an error is raised that can be caught and handled in scripts.