Senin, 14 Februari 2011

Powershell - Powertips: Checking Whether User or Group Exists

I get emails from powershell.com that are worth sharing (and remembering). These are not my scripts. Signup for daily PowerTips here: http://powershell.com/cs/.

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‘)

0 komentar:

Posting Komentar

 
Powered by Blogger