2013-05-29 26 views
0

我試圖導出ADUser屬性,但這個不會在Excel中返回正確的結果,但它在Powershell上顯示正常。Powershell導出Get-ADUser LocaleID問題

代碼:

Get-ADUser username -properties * | Select-Object Name,LocaleID

結果:

Name:User Name
LocaleID:{3}

但是,當我將其導出爲CSV那麼結果是不同的:

代碼:

Get-ADUser username -properties * | Select-Object Name,LocaleID|Export-Csv .\Desktop\aduser.csv

結果在CSV爲的LocaleID是:Microsoft.ActiveDirectory.Management.ADPropertyValueCollection而不是{3}或3

回答

3

的LocaleID是你需要首先展開多值屬性。 另外,請不要加載所有屬性,只需要一個LocaleID屬性即可。

Get-ADUser username -Properties LocaleID | 
Select-Object Name,@{n='LocaleID';e={$_.LocaleID -join ';'}}| 
Export-Csv .\Desktop\aduser.csv 
+0

謝謝謝伊,你又回答了這個問題。 –