This simple powershell script returns True o False if our object is of the same specified type or not.

<# $object contains my username string #>
$object="MyUser"
<# $type contains the type string (User or Group or Computer or OU) #>
$type="User" 

$seek = [System.DirectoryServices.DirectorySearcher]"LDAP://dc=contoso,dc=com"
$seek.Filter = “(&(name=$object)(objectCategory=$type))”
 
Write-Host($seek.FindOne() -ne $null)

Di paolo