June 4, 2020 at 3:37 am #233203ParticipantTopics: 11Replies: 9Points: 110Rank: Participant
Hi Powershell leaders,
Please help me with below scenario.
I have a situation where i am passing csv file as input to powershell script ;
csv file has username , project name , organisation name , dbname and role name. For each line , i am using invoke-restmethod to post data into website .
For each row , after posting via invoke rest method, I am also sending email notification to user with dbname and rolename in email body .
Now , If my csv file has three records where username , project name , organisation name matches except for dbname , role name; then instead of sending email three times , i would like to send a consolidated mail with all dbnames, rolenames for those 3records in my email body.
How can i check if username,projectname,organisation name in a row matches with subsequent rows, get their dbname, rolename , append it to a hash table which can be used to send them in a consolidated email.
Example : In below example, as projectname,orgname,username matches for usera, instead of sending 2 mails, I need to send a single consolidated email to usera with dbname,rolename detailsof both the matching records
username organisationname projectname dbname rolename usera Database Services project1 marketing read usera Database Services project1 sales readWrite userb Database Services project2 sales read userc Database Services project2 marketing readWrite
Please pour few ideas , Thank you in advance
June 4, 2020 at 7:34 am #233218ParticipantTopics: 5Replies: 2384Points: 6,066Rank: Community MVP
You could use Group-Object to group together the rows belonging together. Then you use a nested loop. First you iterate over all groups you created this way. Then – inside this loop – you iterate over all elements of each group.
- You must be logged in to reply to this topic.