嘗試運行腳本時,我收到以下錯誤訊息。
錯誤 :
Add-Member : Cannot add a member with the name "CAllerID*" because a member with that name already exists. To overwrite the member anyway, add the Force parameter to
your command.
腳本 :
$output = Get-ADUser -Identity user -Properties givenName, sn, displayname, samaccountname, title
$output | Add-Member -membertype noteproperty -name "CAllerID*" -value $null | Export-CSV -Path "c:\tmp\users.csv" -NoTypeInformation -Encoding UTF8
uj5u.com熱心網友回復:
在通話中添加-Force和:-PassThruAdd-Member
-Force確保覆寫任何現有的沖突屬性-PassThru導致Add-Member輸出修改后的輸入物件
$output | Add-Member -MemberType NoteProperty -Name "CAllerID*" -Value $null -Force -PassThru | Export-CSV -Path "c:\tmp\users.csv" -NoTypeInformation -Encoding UTF8
如果要進一步修剪回傳的屬性集Get-ADUser,請使用Select-Object:
$output | Select-Object -Property givenName,sn,displayName,SAMAccountName,Title | Add-Member -MemberType NoteProperty -Name "CAllerID*" -Value $null -Force -PassThru | Export-CSV -Path "c:\tmp\users.csv" -NoTypeInformation -Encoding UTF8
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/454129.html
標籤:电源外壳
