Removing Users

Removes the specified User object(s).


Examples:


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


Remove the User "Peer Fekt" in the context "solys.local\Chicago\ITService\Benutzer":


Remove-EmdbUser "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Benutzer\Peer Fekt"


Remove the User "Peer Fekt" from the current context:


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

Remove-EmdbUser "Peer Fekt"


As an alternative method, the following shows the removing of the User "Horst Adler" from the context "solys.local\Chicago\ITService\Users" using the Delete()-method:


$MyUser = Get-EmdbUser "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Users\Horst Adler"

$MyUser.Delete()


Remove the User "Kai Craft" from the context "solys.local\Chicago\ITService\Users" using the cmdlet Remove-Item:


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


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


Starting with PSX 3.1 there was a new option implemented when deleting User 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.