Forum Discussion
12026334
Apr 26, 2021MCT
Bulk Update of Employee Type in Active Directory
Import-module ActiveDirectory $EUserType= Import-CSV "C:\Scripts\EmployeeType21.csv" | % { $User = $_. Name $Type = $_.EmployeeType Set-ADUser $User -Employee-Type $Type } When I run it, I get ...
Joe Hahn
Apr 26, 2021Copper Contributor
The error message points out that there is no parameter named "Employee-Type". Looking at the available parameters for Set-ADUser shows there is also nothing for "employeeType". This means you'll have to use the -Replace to process your updates.
Check if the below code works in your environment, and don't forget to remove "-WhatIf" before running in production. Please note that I removed the $EUserType variable as it wasn't necessary in the script you presented; Import-CSV is piped directly to ForEach-Object.
Import-Module ActiveDirectory
Import-Csv "C:\Scripts\EmployeeType21.csv" |
ForEach-Object {
$User = $_. Name
$Type = $_.EmployeeType
Set-ADUser $User -Replace @{EmployeeType = $Type } -WhatIf
}Timothy Iyamu
Apr 27, 2021Copper Contributor
Joe Hahn, thank you so much, it worked.