I thought I could do this but I am getting errors.
I want to take each user and update several Attributes on the same line as the user in the CSV file.
I have a CSV file that looks like this:
SAMAccountName streetAddress l State POSTALCODE physicalDeliveryOfficeName
Jack.Ripper 1999 Walnut SE Bubblegum KY 22222 NASS - DC 5855
Lizzie.Borden 2777 Walnut SE BadAxe HI 234567 NASS - DC 6407B
Then I run this to see what some attributes look like for Jack and Lizzie:
PS C:\windows\system32> Import-Csv -Path "C:\FolderX\Two.csv" |
foreach {
Get-ADUser -Filter "SamAccountName -like '*$($_.sAMAccountName)*'" -Properties * | select samaccountname, displayname, name, cn, mail, givenname, initials, sn, extensionAttribute8, VVVVTTTTTTAbbreviation, Department, Description, distinguishedname, VVVVofficeid, personguid,streetAddress,state,l,postalCode,physicalDeliveryOfficeName
}
Then I get this:
samaccountname : Jack.Ripper2
displayname : Ripper, Jack - SSSS-ST, Marion, KY
name : Jack.Ripper
cn : Jack.Ripper
mail : Jack.Ripper2@VVVV.KKK
givenname : Jack
initials :
sn : Ripper
extensionAttribute8 : Affiliate
VVVVTTTTTTAbbreviation : SSSS-ST
Department : LMAC-SSSS - SSSS-ST
Description : Delete 03/03/2021 - CRQ3927201 - Account Restricted on 02.08.2021
distinguishedname : CN=Jack.Ripper,OU=Deprovision,OU=Users,OU=LMAC,OU=PLACES,DC=VVVV,DC=net
VVVVofficeid : 108760
personguid : 586B81F9-F4F0-423C-897A-332746F9922D
streetAddress : 1999 Walnut SE
state : KY
l : Bubblegum
postalCode : 22222
physicalDeliveryOfficeName : KYMAR
samaccountname : Lizzie.Borden
displayname : Borden, Lizzie - LMAC-FSA, Roxboro, NC
name : Lizzie.Borden
cn : Lizzie.Borden
mail : Lizzie.Borden@VVVV.KKK
givenname : Lizzie
initials :
sn : Borden
extensionAttribute8 : Affiliate
VVVVTTTTTTAbbreviation : LMAC-FSA
Department : LMAC-FSA
Description : Delete 03/03/2021 - CRQ3927189 - **Account disabled by GGNR 02/06/2021**LMAC-FSA
distinguishedname : CN=Lizzie.Borden,OU=Deprovision,OU=Users,OU=LMAC,OU=PLACES,DC=VVVV,DC=net
VVVVofficeid : 64359
personguid : A1D1E2B1-629F-41A5-A0AB-7BB614B0323C
streetAddress : 2777 Walnut SE
state : HI
l : BadAxe
postalCode : 234567
physicalDeliveryOfficeName : NCROX
Then I run the script:
PS C:\windows\system32>
$Allusers = Import-csv C:\FolderX\Two.csv
Foreach ($user in $AllUsers) {
$Userinfo=Get-ADUser -Identity $user.sAMAccountName -Properties streetAddress,state,l,postalCode,physicalDeliveryOfficeName
Set-ADUser -Identity $user.sAMAccountName -streetAddress $streetAddress -l $l -postalCode $postalCode -physicalDeliveryOfficeName $physicalDeliveryOfficeName}
Get-ADUser -Identity $user.sAMAccountName -Properties SamAccountName,streetAddress,state,l,postalCode,physicalDeliveryOfficeName | ft streetAddress,state,l,postalCode,physicalDeliveryOfficeName
Then it shows this error"
Set-ADUser : A parameter cannot be found that matches parameter name
'physicalDeliveryOfficeName'.
At line:4 char:107
+ ... ess -l $l -postalCode $postalCode -physicalDeliveryOfficeName $physic ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBind
ingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory
.Management.Commands.SetADUser
Set-ADUser : A parameter cannot be found that matches parameter name
'physicalDeliveryOfficeName'.
At line:4 char:107
+ ... ess -l $l -postalCode $postalCode -physicalDeliveryOfficeName $physic ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-ADUser], ParameterBind
ingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory
.Management.Commands.SetADUser
streetAddress state l postalCode physicalDeliveryOfficeName
------------- ----- - ---------- --------------------------
2777 Walnut SE HI BadAxe 234567 NCROX
PS C:\windows\system32>
And nothing is updated. I tried updating only one attribute at a time but that doesn’t work either.
Where am I going wrong?
This Attribute: physicalDeliveryOfficeName - This is the real name of the attribute. And it seems to be alright and show up along with other attributes. Why won’t it work in the script to Set-ADUser?
Thanks in advance.