chb1982
Goto Top

Exchange Powershell - export-csv

Moin zusammen,

einfache Frage:

auf einem Exchange versuche ich folgendes:

[PS] C:\tmp>Get-Mailbox | where {$_.PrimarySmtpAddress -Match "test123.de"}  | Format-Table Displayname, PrimarySmtpAddress | export-csv c:\tmp\123.csv  


Das Ergebnis in der CSV-Datei ist allerdings nicht das, was ich ohne export-csv auf dem Bildschirm angezeigt bekomme.
In der steht nämlich nur noch:


#TYPE Microsoft.PowerShell.Commands.Internal.Format.FormatStartData
"ClassId2e4f51ef21dd47e99d3c952918aff9cd","pageHeaderEntry","pageFooterEntry","autosizeInfo","shapeInfo","groupingEntry"
"033ecb2bc07a4d43b5ef94ed5a35d280",,,,"Microsoft.PowerShell.Commands.Internal.Format.TableHeaderInfo",
"9e210fe47d09416682b841769c78b8a3",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
"27c87ef9bbda4f709f6b4002fa4af63c",,,,,
.
.
.

Was mache ich da falsch?

Content-Key: 359277

Url: https://administrator.de/contentid/359277

Printed on: April 19, 2024 at 13:04 o'clock

Member: chb1982
chb1982 Dec 27, 2017 at 14:56:29 (UTC)
Goto Top
Hab mir die Lösung selbst gegeben.

Korrekt ist
[PS] C:\tmp>Get-Mailbox | where {$_.PrimarySmtpAddress -Match "test123.de"}  | Select Displayname, PrimarySmtpAddress | export-csv c:\tmp\123.csv  

Select statt Format-Table
Mitglied: 135051
Solution 135051 Dec 27, 2017 updated at 14:57:22 (UTC)
Goto Top
Das Format-Table durch select ersetzen! Export-CSV erwartet Objects keine String-Formatierung.

Gruß
Member: chb1982
chb1982 Dec 27, 2017 at 14:58:37 (UTC)
Goto Top
Danke! Das hatte ich kurz nach dem Klicken auch selbst gesehen bzw. gefunden face-smile

Danke für die Hilfe.

Jetzt muss ich nur noch raus finden, wie ich auch Umlaute sauber in die csv bekomme und schon bin ich happy
Mitglied: 135051
Solution 135051 Dec 27, 2017 updated at 15:01:40 (UTC)
Goto Top
Zitat von @chb1982:
Jetzt muss ich nur noch raus finden, wie ich auch Umlaute sauber in die csv bekomme und schon bin ich happy
-Encoding UTF8 bei Export-CSV am Ende setzen.

...... | export-csv "c:\tmp\123.csv" -Delimiter ";" -NoType -Encoding UTF8  
Member: chb1982
chb1982 Dec 27, 2017 at 15:17:11 (UTC)
Goto Top
Danke!