Hello everyone, I’ have a csv file (; delimiter and as columns: samaccountname, extensionattribute2,extensionattribute1, employeeid, userprincipalname, extensionattribute3, extensionattribute4 and extensionattribute5. The goal is that it check for every user (samaccountname) if the other fields are already filled in, if not it needs to add the values from the csv file. The problem is it worked for 1 line, but when I added a 2nd row it didn’t work.<\/p>\n
Import-Module ActiveDirectory\nImport-Csv -Path \".\\test2.csv\" -delimiter \";\" | ForEach-Object {\n Set-ADUser $_.samAccountName -add @{\n ExtensionAttribute1 = \"$($_.ExtensionAttribute1)\"\n ExtensionAttribute2 = \"$($_.ExtensionAttribute2)\"\n ExtensionAttribute3 = \"$($_.ExtensionAttribute3)\"\n ExtensionAttribute4 = \"$($_.ExtensionAttribute4)\"\n ExtensionAttribute5 = \"$($_.ExtensionAttribute5)\"\n EmployeeID = \"$($_.EmployeeID)\"\n UserPrincipalName = \"$($_.Userprincipalname)\"\n }\n}\n<\/code><\/pre>\n
Advertisement
This is the script was using, but probably I’ve done something wrong.<\/p>\n
Advertisement
Jo<\/p>","upvoteCount":4,"answerCount":3,"datePublished":"2024-12-16T09:51:53.740Z","author":{"@type":"Person","name":"Vanattenhoven-Jo","url":"https://community.spiceworks.com/u/Vanattenhoven-Jo"},"acceptedAnswer":{"@type":"Answer","text":"
For the second row, did the script throw an error, or did it populate incorrect values?<\/p>","upvoteCount":1,"datePublished":"2024-12-16T14:09:29.266Z","url":"https://community.spiceworks.com/t/needing-help-with-powershell-to-update-add-data-in-ad/1154055/2","author":{"@type":"Person","name":"Evan7191","url":"https://community.spiceworks.com/u/Evan7191"}},"suggestedAnswer":[{"@type":"Answer","text":"
Hello everyone, I’ have a csv file (; delimiter and as columns: samaccountname, extensionattribute2,extensionattribute1, employeeid, userprincipalname, extensionattribute3, extensionattribute4 and extensionattribute5. The goal is that it check for every user (samaccountname) if the other fields are already filled in, if not it needs to add the values from the csv file. The problem is it worked for 1 line, but when I added a 2nd row it didn’t work.<\/p>\n
Import-Module ActiveDirectory\nImport-Csv -Path \".\\test2.csv\" -delimiter \";\" | ForEach-Object {\n Set-ADUser $_.samAccountName -add @{\n ExtensionAttribute1 = \"$($_.ExtensionAttribute1)\"\n ExtensionAttribute2 = \"$($_.ExtensionAttribute2)\"\n ExtensionAttribute3 = \"$($_.ExtensionAttribute3)\"\n ExtensionAttribute4 = \"$($_.ExtensionAttribute4)\"\n ExtensionAttribute5 = \"$($_.ExtensionAttribute5)\"\n EmployeeID = \"$($_.EmployeeID)\"\n UserPrincipalName = \"$($_.Userprincipalname)\"\n }\n}\n<\/code><\/pre>\nThis is the script was using, but probably I’ve done something wrong.<\/p>\n
Jo<\/p>","upvoteCount":4,"datePublished":"2024-12-16T09:51:53.815Z","url":"https://community.spiceworks.com/t/needing-help-with-powershell-to-update-add-data-in-ad/1154055/1","author":{"@type":"Person","name":"Vanattenhoven-Jo","url":"https://community.spiceworks.com/u/Vanattenhoven-Jo"}},{"@type":"Answer","text":"
For some reason it is working now. I’m getting errors but those can be handled. The biggest part is handled correctly. My apologies.<\/p>","upvoteCount":2,"datePublished":"2024-12-16T14:26:31.451Z","url":"https://community.spiceworks.com/t/needing-help-with-powershell-to-update-add-data-in-ad/1154055/3","author":{"@type":"Person","name":"Vanattenhoven-Jo","url":"https://community.spiceworks.com/u/Vanattenhoven-Jo"}}]}}