Thursday 18 July 2013

Find if AD user or Group exists by using PowerShell

Quickpost

I just needed a fast and quick way to find out if a security group exists in Active Directory via PowerShell for some SharePointregarding business. I actually had to spend a little time searching for this, the simplest of solutions.

PowerShell prompt:

[ADSI]::Exists('WinNT://./usernameorgroup') <- Local users or groups
or
[ADSI]::Exists('WinNT://domainname/usernameorgroup') <- Domain users or groups

This will return true or false.

For my purposes this was exactly what I needed. What limitations this have in regards to security I don't know. But the user i ran this commands with is not a domain admin or has any elevated rights above admin on the said server.

No comments:

Post a Comment