get-aduser info

I need to run a GPO that will collect info from the user that logs in. The user logs into the computer gets the samaccountname and uses get-aduser to collect full name and email address. My question is: If the client machine does not have the ad module do I need to import it or will the server handle it

i do not know whether this will be handled by the workstation or the server, but i do know that you don’t need the ad module to get the information you mentioned

$userinfo = [pscustomobject][hashtable]([adsisearcher]"samaccountname=$env:USERNAME").findone().properties
$userinfo.name
$userinfo.mail

This is what I have so far:

$username = $env:USERNAME
$Filter = "(&(objectCategory=User)(SamAccountName=$UserName))"
$Searcher = New-Object System.DirectoryServices.DirectorySearcher
$Searcher.Filter = $Filter
$ADUserPath = $Searcher.Findone()
$ADUser = $ADUserPath.GetDirectoryEntry()
$ADDisplayName = $ADUser.displayName
$ADEmailAddress = $ADUser.mail
$ADTitle = $ADUser.title 
$ADDescription = $ADUser.description 
$ADTelePhoneNumber = $ADUser.TelephoneNumber 
#$ADMobile = $ADUser.mobile 
$ADStreetAddress = $ADUser.streetaddress 
#$ADCity = $ADUser.l 
$ADDepartment = $ADUser.department 

The only one that works and returns a value is displayname. Can someone help me fix it

try changing this

$ADUser = $ADUserPath.GetDirectoryEntry()

to this

$ADUser = $ADUserPath.Properties

How can I get the same properties with adsi. as with get-aduser .I can get the emailaddress property using get-aduser but not with adsi. Can You help me.

There may be some useful information here
https://m.reddit.com/r/PowerShell/comments/4isxb6?sort=confidence&utm_source=mweb_redirect&compact=true