If you want to check the existence of any user or group in Windows Active Directory, use the following PowerShell script.

PowerShell: Check if AD User or Group Exists

Step 1. Open PowerShell with elevated privileges.

Step 2. Execute the following script:

$userobj = Get-ADUser -LDAPFilter "(SAMAccountName=$username)"

$vlanobj = Get-ADGroup -LDAPFilter "(SAMAccountName=$vlangroupname)"

if ($userobj -eq $null) {"User not valid"}
if ($vlanobj -eq $null) {"VLAN not valid"}

 

How to Check if a User or Group Exists in AD using PowerShell

Leave a Reply

Your email address will not be published. Required fields are marked *

*

Ad #native_company# — #native_desc# #native_cta#