How to know if $variable is User or group
hello all,
i use finding best way know if "name" saved in variable ad user or ad group.
any ideas on how find it?
regards,
arestas
function what-ami($object) { $user = get-aduser -ldapfilter "(samaccountname=$object)" if ($user -ne $null) {'user'} else { $group = get-adgroup -ldapfilter "(samaccountname=$object)" if ($group -ne $null) {'group'} else { $computer = get-adcomputer -ldapfilter "(samaccountname=$object)" if ($user -ne $null) {'computer'} else {'object not found in ad'} } } } what-ami 'the name want check'or if exsits check $variable.objectclass
Windows Server > Windows PowerShell
Comments
Post a Comment