It is common for organisations to use or create Active Directory Attributes that may contain multiple different values and when trying to obtain the information using PowerShell you might receive
Microsoft.ActiveDirectory.Management.ADPropertyValueCollection
Which isn’t helpful to man or beast. However, I have been recently working with custom attributes so its time to share my experiences once again. In this
# Command
Get-ADUser -Properties * -Filter * | Select-Object samaccountname,customattribute10 | export-csv -Path $env:USERPROFILE\desktop\test1.csv

As you can see that from the above I am not receiving the desired output from Get-ADUser. So
Let’s discuss the below string in detail to explain what each part does
@{name=” customattribute10 ”;expression={$_. customattribute10}}
The @
@{name=” customattribute10 ”;
Then you provide an expression; this is the script block where you tell the PowerShell cmdlet what you are trying to fetch. For example; we want to fetch the values for the customattribute10 attribute.
expression={$_. customattribute10}}
So, now we understand the require array to pull the multi-values from lets execute the below command
# Command
Get-ADUser -Filter * -Properties proxyaddresses,customattribute10 | select samaccountname, @{L='customAttribute10'; E={$_.customAttribute10}} | Export-Csv -Path $env:USERPROFILE\desktop\test.csv
Now executing this command you will receive the correct output from the attribute which you desired.
Regards
The Author – Blogabout.Cloud