我需要批量更新多个广告用户对象的“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”)
}
答案 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()
}