WorkstationList.csv has 3 separate columns with different names. Trying to use a column "retired" that has a list of retired logonworkstations names and match them to a users current list. If there is a match then delete from the users logonworkstation list.
$defaultWorkstationslist = Import-Csv -Path '[workstationList.csv]'
$olist = Get-Aduser $user-Properties LogonWorkstations | Select LogonWorkstations
$newlist = ''
foreach ($o in $olist){
foreach ($r in $defaultWorkstationslist.retired){
if ($o -ne $r){
$newlist += $o
} else {
continue
}
}
}
Set-ADUser $user -logonWorkstations $newlist
Output:
Set-ADUser : The format of the specified computer name is invalid
[redacted]:36 char:1
+ Set-ADUser $user-logonWorkstations $newlist
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (user:ADUser) [Set-ADUser], ADException
+ FullyQualifiedErrorId : ActiveDirectoryServer:1210,Microsoft.ActiveDirectory.Management.Commands.SetADUser