Forum Discussion
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 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
5 Replies
- Timothy370Copper Contributor
How can i manage my users from deleting files from onedrive and sharepoint without making the users know that they are monitored and cannot delete files permanently
- Timothy370Copper ContributorJoe Hahn, How can i manage my users from deleting files from onedrive and sharepoint without making the users know that they are monitored and cannot delete files permanently
- Joe HahnCopper 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 IyamuCopper ContributorJoe Hahn, thank you so much, it worked.
- SeshadrrIron ContributorCheck your input csv has header referred to EmployeeType