Checking Whether User or Group Exists

by Dec 30, 2010

To find out whether a given local or domain user/group exists, you can simply use the static method Exists():

[ADSI]::Exists('WinNT://./Tobias1')

This will check whether there is a local account named "Tobias1." To check domain accounts, you can simply replace "." with your domain name, or use LDAP:

[ADSI]::Exists('LDAP://CN=Testuser,CN=Users,DC=YourDomain,DC=Com')

Twitter This Tip!
ReTweet this Tip!