将计算机添加到用户的 LogonWorkstation 而不覆盖以前的工作站
Adding computer to LogonWorkstation for user without overwriting previous Workstations
我正在使用这个命令
Set-ADUser xyz -LogonWorkstations "$sysName1,$sysName1"
如果我将第三个系统添加到 xyz 用户,那么之前的系统将被第三个系统覆盖。我想在添加这两个系统的同时添加第三个系统。
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
}
我正在使用这个命令
Set-ADUser xyz -LogonWorkstations "$sysName1,$sysName1"
如果我将第三个系统添加到 xyz 用户,那么之前的系统将被第三个系统覆盖。我想在添加这两个系统的同时添加第三个系统。
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
}