I have a spreadsheet with two columns, column A has the samAccountName and column B empty. I want to populate B using column A as a reference for each account. I want to pull attribute Title into column B and update the spreadsheet. I am open to creating a new spreadsheet or even keeping the data in powershell grid formatting, I just need to keep the order of my spreadsheet so I can copy it back into the master list<\/p>\n
$USERS = Import-Csv “path\\csv.csv”<\/p>\n
ForEach ($User in $USERS) { This gives me error - Get-ADUser : Cannot validate argument on parameter ‘Identity’. The argument is null. Provide a valid value for the argument, and then try running the command again.<\/p>\n I know my syntax is jacked, but I am new to powershell and have java and python experience.<\/p>\n Thanks, there are 2 foreach in powershell, there is foreach-object (that is used with $_) and there is foreach.<\/p>\n They are different.<\/p>\n try like so:<\/p>\n I have a spreadsheet with two columns, column A has the samAccountName and column B empty. I want to populate B using column A as a reference for each account. I want to pull attribute Title into column B and update the spreadsheet. I am open to creating a new spreadsheet or even keeping the data in powershell grid formatting, I just need to keep the order of my spreadsheet so I can copy it back into the master list<\/p>\n $USERS = Import-Csv “path\\csv.csv”<\/p>\n ForEach ($User in $USERS) { This gives me error - Get-ADUser : Cannot validate argument on parameter ‘Identity’. The argument is null. Provide a valid value for the argument, and then try running the command again.<\/p>\n I know my syntax is jacked, but I am new to powershell and have java and python experience.<\/p>\n Thanks, Welcome<\/p>\n If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n
\n$.umbTitle = Get-ADUser -Identity $<\/em>.samAccountname -properties Title
\n}<\/p>\n
\nJesse<\/p>","upvoteCount":7,"answerCount":10,"datePublished":"2021-08-30T14:48:53.000Z","author":{"@type":"Person","name":"spiceuser-buscr","url":"https://community.spiceworks.com/u/spiceuser-buscr"},"acceptedAnswer":{"@type":"Answer","text":"$USERS = Import-Csv \"path\\csv.csv\"\n\n$newCSV = \nForEach ($User in $USERS) {\n [pscustomobject]@{\n Samaccountname = $user.samaccountname\n Title = (Get-ADUser -Identity $User.samAccountname -properties Title).title\n }\n}\n\n$newCSV |\nexport-csv \".\\file.csv\" -NoTypeInformation\n<\/code><\/pre>","upvoteCount":0,"datePublished":"2021-08-30T15:12:37.000Z","url":"https://community.spiceworks.com/t/powershell-update-csv/809775/4","author":{"@type":"Person","name":"Neally","url":"https://community.spiceworks.com/u/Neally"}},"suggestedAnswer":[{"@type":"Answer","text":"
\n$.umbTitle = Get-ADUser -Identity $<\/em>.samAccountname -properties Title
\n}<\/p>\n
\nJesse<\/p>","upvoteCount":7,"datePublished":"2021-08-30T14:48:53.000Z","url":"https://community.spiceworks.com/t/powershell-update-csv/809775/1","author":{"@type":"Person","name":"spiceuser-buscr","url":"https://community.spiceworks.com/u/spiceuser-buscr"}},{"@type":"Answer","text":"