Apr 26 2021 09:49 AM
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
Apr 26 2021 09:59 AM
Apr 26 2021 12:37 PM
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
}
Apr 27 2021 12:21 AM
Aug 28 2022 01:25 PM
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
Aug 28 2022 01:26 PM