i'm getting some problem to get a specific row from a powershell body. HR team send email to us, a logic app get the body of email and pass it to a script that disable the user.
The body is like this:
Hi,
the following user have to be dismiss:
#mail: user1@mycompany.com
#mail: user2@mycompany.com
#mail: user2@mycompany.com
Bye
hr team
hrteam@mycompany.com
i would like to get only the specific row:
#mail: user1@mycompany.com
#mail: user2@mycompany.com
#mail: user2@mycompany.com
to do this i did a trick with following code:
$Body
$SplitBody = $Body.split("").split(" ").Split("#")
$objetbody = $SplitBody.Replace(" ","").Trim()
and i got following result:
Hi,
the
following
user
have
to
be
dismiss:
mail:
user1@mycompany.com
mail:
user2@mycompany.com
mail:
user2@mycompany.com
Bye
hr
team
hrteam@mycompany.com
after that i pass $objetbody into a foreach and loop all row(at the end of this foreach is put a break becouse it can disable HR mail). The flow work if HR sent only 1 mail to disable.
My question is there is a way to got that specific row that contains the mails?
Thanks