更新AD tsprofilepath并将字符串追加到路径名中的变量

时间:2016-03-31 20:00:14

标签: powershell active-directory

我需要批量更新多个广告用户对象的“terminalservicesprofilepath”属性,并在路径末尾附加变量+字符串。到目前为止,这就是我所拥有的,这是悲惨的。

$users = (gc C:\Scripts\users.txt |%{get-aduser $_ })
FOREACH ($user in $users){
$profiledir = $user + ".DOMAIN.V2"
$x = [ADSI]”LDAP://$($user.DistinguishedName)”
$x.psbase.invokeset(“terminalservicesprofilepath”,”\\Fileserver\tsprofile\$profiledir”)
}

1 个答案:

答案 0 :(得分:0)

$users = (gc C:\SCRIPTS\test.txt |%{get-aduser $_ })
FOREACH ($user in $users){
$profiledir = $($user.samaccountname) + '.DOMAIN.V2'
$tsppath = "\\FILESERVER\$profiledir"
$x = [ADSI]”LDAP://$($user.DistinguishedName)”
$x.psbase.invokeset(“terminalservicesprofilepath”,”$tsppath”)
$x.setinfo()
}