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

Popular posts from this blog

Motherboard replacement

Cannot create Full Text Search catalog after upgrading to V12 - Database is not fully started up or it is not in an ONLINE state

Remote Desktop App - Error 0x207 or 0x607