I have a user that is in a department that I can pull the department with the following line
$UserDepartment = Get-ADUser $UserName -Property Department | Select-Object Department
Write-Host $UserDepartment
which returns: @{Department=SALES}
I need a way to take the user out of the department while not deleting the user and wasn't sure how to go about it
CodePudding user response:
If you want to clear a user's attribute you should use the -Clear
parameter.
See the Parameters section for this cmdlet.
Set-ADUser $user -Clear Department
CodePudding user response:
You could do something like
Get-ADUser $UserName | Set-ADUser -Department “”
If you wish to mearly clear the department property
You can check out the powershell documentation for it here