Share via


以get-adgroup PowerShell指令輸出csv檔時,部分欄位值出現異常

問題:

當您以get-adgroup搭配Export-Csv 指令輸出為csv檔時,部分欄位值被變更為 "Microsoft.ActiveDirectory.Management.ADPropertyValueCollection"

原指令:

get-adgroup -filter * -Properties * | select-object name,mail,description,ManagedBy,dlMemSubmitPerms | Export-Csv c:\adgroup.csv

輸出結果:

clip_image002

修改後的指令:

get-adgroup -filter * -Properties * | select-object name,mail,description,ManagedBy,@{n="dlMemSubmitPerms";e={[string]$_.dlMemSubmitPerms}} | Export-Csv c:\adgroup.csv

參考資料:

Can't query some attributes

https://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/eb58b98b-cd3f-4ad9-b75f-cf50abb80d31

Windows PowerShell Tip of the Week

https://technet.microsoft.com/en-us/library/ee692794.aspx