I have a .csv file that I am using to modify custom attributes on users in Active Directory, but PowerShell does not like the script:
Import-Csv -path c:\users\user\desktop\doc.csv | ForEach-Object {
Set-ADUser $_.mail -replace @{
ExtensionAttribute1 = $_.ExtensionAttribute1
}
}
I get the following error:
Set-ADUser : replace
At line:2 char:4
Set-ADUser $_.mail -replace @{
CategoryInfo: InvalidOperation: (user123:ADUser) [Set-ADUser], ADInvalidOperationException
FullyQualifiedErrorId: ActiveDirectoryServer:0,Microsoft.ActiveDirectory.Management.Commands.SetADUser
The CSV only has 2 columns:
extensionAttribute1,mail
Any help would be appreciated
@and the opening bracket{Set-ADUser, nor is it valid to have the pipe (|) in a new line. also, you need have the opening brace forForeach-Objectin the same line unless you you use a continuation/escape mark: the back tick: `.There's no-Replaceparameter, and if you're referring to the operator, it's still invalid syntax for that as well. What are your intentions? What is the expected result?-Replaceis a parameter. Thank you!:)