将字符串添加到ad-user的选定属性

时间:2015-03-24 07:44:05

标签: powershell active-directory

如何添加文字" test"到每个选定用户的HomeDrive-Path的末尾?

Get-ADUser -filter * -properties EmailAddress, HomeDirectory -SearchBase "OU=Teacher,OU=__User Accounts,DC=school,DC=local" | 
    select EmailAddress, HomeDirectory |
    ConvertTo-Csv | 
    Out-File c:\temp\teacher.csv

1 个答案:

答案 0 :(得分:0)

您可以使用选择表达式:

Get-ADUser -filter * -properties EmailAddress, HomeDirectory -SearchBase "OU=Teacher,OU=__User Accounts,DC=school,DC=local" | 
    select EmailAddress, @{l="HomeDirectory"; e={"{0}test" -f $_.HomeDirectory}} |
    ConvertTo-Csv | 
    Out-File c:\temp\teacher.csv

哪里" l"是新物业的标签," e"是属性的定义/表达式(在本例中,它是一个格式字符串)