Powershell – Allow and Parse Multiple Line Paste

I'm working on a PS script that will allow a user to paste a bunch of emails on the command line, then the script will parse each one out and run another function on them.

I've looked around for a solution as well as played around in VS Code, but nothing seems to work how I would like it.

The format of the pasted emails by the user will be as follows, copied from a txt file:

1@mail.com
2@mail.com
3@mail.com

Each email separated by a newline.

Using Read-Host, if I paste multiple lines, it just takes the first line, runs whatever function I have on it, then errors out on the next lines.

Essentially I'd like input/output to look like this:

Paste emails: 
1@mail.com
2@mail.com
3@mail.com

Operation was performed on email 1@mail.com
Operation was performed on email 2@mail.com
Operation was performed on email 3@mail.com

Any help would be much appreciated. Thank you!



Read more here: https://stackoverflow.com/questions/68474552/powershell-allow-and-parse-multiple-line-paste

Content Attribution

This content was originally published by CDav117 at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: