我正在使用此命令
Set-ADUser xyz -LogonWorkstations "$sysName1,$sysName1"
如果我向xyz用户添加第三个系统,那么之前的系统会被第三个系统覆盖。我想添加第三个系统以及这两个系统。
答案 0 :(得分:1)
LogonWorkstations
属性是一个逗号分隔的字符串,因此您可以获取其值,然后在分配之前将新工作站添加到此。
$User = "xyz"
$NewWorkstation = "Workstation03"
$LogonWorkstations = Get-AdUser -Identity $User -Properties LogonWorkstations | select -ExpandProperty LogonWorkstations #get current computernames that user can access
if ($LogonWorkstations) {
Set-ADUser -Identity $User -LogonWorkstations "$LogonWorkstations,$NewWorkstation" #add new workstation to existing entries
}
else {
Set-ADUser -Identity $User -LogonWorkstations $NewWorkstation #only add new workstation
}