I am trying to query AD for a list of users and a particular variable like so:
get-aduser -filter * -Properties * | select Samaccountname,vasco-LinkUserToDPToken | Export-Csv U:\test.csv -NoTypeInformation
However this returns the samaccountname and Microsoft.ActiveDirectory.Management.ADPropertyValueCollection.
Looking at the web I have ascertained that this property is a collection and I would need something along the lines of this to expand it and allow it to be exported to CSV:
get-aduser -filter * -Properties * | select @{name="vasco";expression={$_.vasco-LinkUserToDPToken -join}},samaccountname | Export-Csv U:\test.csv -NoTypeInformation
However I keep getting the following error:
Unexpected token '-LinkUserToDPToken' in expression or statement.
I am guessing that powershell is reading the "-" as some form of operator and dooming out. Unfortunately I cant find a way round it. I understand ` is the escape character but my blunt force usage of it has yielded no useable results. I was hoping someone might be able to help usher me in the right direction. It could well be that my frantic blog post reading has led to me misunderstanding the hash table usage syntax as well...
I have encountered this before in our environment and the trick is the use double quotes after the $_.
sign variable like this. $_."vasco-LinkDPToUserToken"
get-aduser -filter * -Properties * | select @{name="vasco";expression={$_."vasco-LinkUserToDPToken" -join}},samaccountname | Export-Csv U:\test.csv -NoTypeInformation