New Powershell user here and I am looking for some insight. I have to pull the following items from Active Directory and dump them into a spreadsheet…
extensionAttribute1
extensionAttribute2
Department
Is it possible to pull this information using “objectGUID” ? I have over 2000 AD users/objects that I need to pull this info so we can import it into GCDS (Google Cloud). Any help would be much appreciated!
In Powershell, most cmdlets will return default properties. You can see in the example below with Get-Service, only 3 properties are returned, the others hidden until we do Select -Properties *:
For WMI and Active Directory, only certain properties are returned in the resultset, simply for speed. Returning 10 properties or 100 properties multiplied by the number of objects (like 1000 users) is going to return at much different performance levels. As postanote eluded, you need to tell the cmdlet that you want additional properties returned in the query. Using -Properties * will return ALL properties. You can also specify just the properties you require to increase performance:
foreach ($obj in $objectlist) {
$aduser = Get-ADUser “$($obj.ObjectGUID)” -Properties department, extensionAttribute1, extensionAttribute2, ObjectGUID
Write “Dept is $($aduser.department) extAtt1 is ‘$($aduser.extensionAttribute1)’ extAtt2 is ‘$($aduser.extensionAttribute2)’”
}
The Write command is in there purely for testing to make sure that it’s returning values (which it is). Now I just need to export that data to a csv. Granted I have only tested this against users, not contacts or groups yet. I appreciate the input.