Most likely you're getting a collection of objects in your data. You have to expand or join the data before passing to Export-CSV
See the following articles for some idea:
1) http://blog.millersystems.com/powershell-exporting-multi-valued-attributes-via-export-csv-cmdlet/
2) http://www.msexchange.org/kbase/ExchangeServerTips/ExchangeServer2010/Powershell/WhydoIgetSystem.StringwhenusingGet-MessageTrackingLogandexportingtoaCSV.html
The articles give the following examples:
1) change the following
Get-TransportServer | Get-MessageTrackingLog -ResultSize -Start "11/28/2011" -Sender [email protected] | Select * | Export-Csv D:\Reports\Sent_Nuno.csv -NoType
to
Get-TransportServer | Get-MessageTrackingLog -ResultSize -Start "11/28/2011" -Sender [email protected] | Select {$_.Recipients}, {$_.RecipientStatus}, * | Export-Csv D:\Reports\Sent_Nuno.csv -NoType
2) change the following
Get-QADUser seth -IncludeAllProperties | select name, proxyaddresses | Export-Csv .seth-nojoin.csv - See more at: http://blog.millersystems.com/powershell-exporting-multi-valued-attributes-via-export-csv-cmdlet/#sthash.JCccKLui.dpuf
to
Get-QADUser seth -IncludeAllProperties | select name, @{Name=’proxyAddresses';Expression={[string]::join(“;”, ($_.proxyAddresses))}} | Export-Csv .seth-all_proxyaddresses.csv - See more at: http://blog.millersystems.com/powershell-exporting-multi-valued-attributes-via-export-csv-cmdlet/#sthash.JCccKLui.dpuf
You'll need to import the ActiveDirectory module for the get-ADGroupMember cmdlet, but I assume you've already gotten past that part as you have output instead of errors. I don't have the ability to test currently as I can't import the module (need RSAT or AD Management Gateway Service installed), but I think you would need to insert a select command in your pipeline (to enumerate the problematic data fields) that looks something like this:
powershell.exe get-adgroupmember "$SG" | Select {$_.nameOfVariableReturningSystemString}, * | export-csv -path "C:\users\$uni\desktop\members.csv
powershell.exe
and add-NoTypeInformation
switch:get-adgroupmember "$SG" | export-csv -path "C:\users\$uni\desktop\members.csv" -NoTypeInformation
. – Alexander ObershtGet-ADGroupmember
is not a stock cmdlet. You need to import ActiveDirectory module first (and probably install RSAT to be able to do that). – Alexander ObershtImport-Module
toGet-ADGroupMember
. Instead make them separate commands. Perhaps this example can illustrate what I mean? – Alexander Obersht