Bulk Update of Employee Type in Active Directory

%3CLINGO-SUB%20id%3D%22lingo-sub-2293672%22%20slang%3D%22en-US%22%3EBulk%20Update%20of%20Employee%20Type%20in%20Active%20Directory%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2293672%22%20slang%3D%22en-US%22%3E%3CP%3EImport-module%20ActiveDirectory%3CBR%20%2F%3E%24EUserType%3D%20Import-CSV%20%22C%3A%5CScripts%5CEmployeeType21.csv%22%20%7C%20%25%20%7B%3CBR%20%2F%3E%24User%20%3D%20%24_.%20Name%3CBR%20%2F%3E%24Type%20%3D%20%24_.EmployeeType%3CBR%20%2F%3ESet-ADUser%20%24User%20-Employee-Type%20%24Type%3CBR%20%2F%3E%7D%3CBR%20%2F%3EWhen%20I%20run%20it%2C%20I%20get%20the%20Following%20error%3A%3C%2FP%3E%3CP%3ESet-ADUser%20%3A%20A%20parameter%20cannot%20be%20found%20that%20matches%20parameter%20name%20'Employee-Type'.%3C%2FP%3E%3CP%3EAt%20line%3A4%20char%3A18%3C%2FP%3E%3CP%3E%2B%20Set-ADUser%20%24User%20-Employee-Type%20%24Type%3C%2FP%3E%3CP%3E%2B%20~~~~~~~~~~~~~~%3C%2FP%3E%3CP%3E%2B%20CategoryInfo%20%3A%20InvalidArgument%3A%20(%3A)%20%5BSet-ADUser%5D%2C%20ParameterBindingException%3C%2FP%3E%3CP%3E%2B%20FullyQualifiedErrorId%20%3A%20NamedParameterNotFound%2CMicrosoft.ActiveDirectory.Management.Commands.SetADUser%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20i%20need%20help%20to%20fix%20this%2C%20please%20share%20the%20specific%20parameters%20are%20need%20to%20modify%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2293672%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2293739%22%20slang%3D%22en-US%22%3ERe%3A%20Bulk%20Update%20of%20Employee%20Type%20in%20Active%20Directory%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2293739%22%20slang%3D%22en-US%22%3ECheck%20your%20input%20csv%20has%20header%20referred%20to%20EmployeeType%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2294464%22%20slang%3D%22en-US%22%3ERe%3A%20Bulk%20Update%20of%20Employee%20Type%20in%20Active%20Directory%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2294464%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F941122%22%20target%3D%22_blank%22%3E%40IyamuT31%3C%2FA%3E%2C%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20error%20message%20points%20out%20that%20there%20is%20no%20parameter%20named%20%22Employee-Type%22.%26nbsp%3B%20Looking%20at%20the%20available%20parameters%20for%20Set-ADUser%20shows%20there%20is%20also%20nothing%20for%20%22employeeType%22.%26nbsp%3B%20This%20means%20you'll%20have%20to%20use%20the%20-Replace%20to%20process%20your%20updates.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECheck%20if%20the%20below%20code%20works%20in%20your%20environment%2C%26nbsp%3Band%26nbsp%3Bdon't%20forget%20to%20remove%20%22-WhatIf%22%20before%20running%20in%20production.%26nbsp%3B%20Please%20note%20that%20I%20removed%20the%26nbsp%3B%24EUserType%20variable%20as%20it%20wasn't%20necessary%20in%20the%20script%20you%20presented%3B%20Import-CSV%20is%20piped%20directly%20to%20ForEach-Object.%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3EImport-Module%20ActiveDirectory%0AImport-Csv%20%22C%3A%5CScripts%5CEmployeeType21.csv%22%20%7C%20%0A%20%20%20%20ForEach-Object%20%7B%0A%20%20%20%20%20%20%20%20%24User%20%3D%20%24_.%20Name%0A%20%20%20%20%20%20%20%20%24Type%20%3D%20%24_.EmployeeType%0A%20%20%20%20%20%20%20%20Set-ADUser%20%24User%20-Replace%20%40%7BEmployeeType%20%3D%20%24Type%20%7D%20-WhatIf%0A%20%20%20%20%7D%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2296404%22%20slang%3D%22en-US%22%3ERe%3A%20Bulk%20Update%20of%20Employee%20Type%20in%20Active%20Directory%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2296404%22%20slang%3D%22en-US%22%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F234304%22%20target%3D%22_blank%22%3E%40Joe%20Hahn%3C%2FA%3E%2C%20thank%20you%20so%20much%2C%20it%20worked.%3C%2FLINGO-BODY%3E
New Contributor

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 the Following error:

Set-ADUser : A parameter cannot be found that matches parameter name 'Employee-Type'.

At line:4 char:18

+ Set-ADUser $User -Employee-Type $Type

+ ~~~~~~~~~~~~~~

+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBindingException

+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory.Management.Commands.SetADUser

 

Please i need help to fix this, please share the specific parameters are need to modify

3 Replies
Check your input csv has header referred to EmployeeType

@IyamuT31

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
    }
@Joe Hahn, thank you so much, it worked.