Hello All,<\/p>\n
I am just starting my voyage into Powershell and one of the things I am currently trying to do is write a Script to create a MS Team. I have created plenty of teams already from powershell but I want to make it so anyone in my team even student workers with no know how could just run my script.<\/p>\n
Capturing simple variables like the name, description, owner and such have been easy. The part I am trying to figure out is how to capture all of the members to be added.<\/p>\n
In my mind I see something roughly along the lines of this. I know it won’t work I just don’t know how to increment a user input variable until a condition is met and capture each as a unique variable that I can call later.<\/p>\n
$member = (read-host \"What is the email address of the member you want to add?\")\n$moreUsers = (read-host \"Do you want to add more users? Yes or No?\")\nwhile ($moreUsers -notlike \"no\")\n {\n increment something here on $member for capture\n $member2 = (read-host \"What is the email address of the member you want to add?\")\n $moreUsers = (read-host \"Do you want to add more users? Yes or No?\")\n }\n<\/code><\/pre>\nIf anybody could point me to a good primer on capturing user input like this that would increment until a condition would be met that would be great or give me a hand on making that butchered nonsense above into something working. Any tips are welcome. I am enjoying the flexibility with powershell but I have a long ways to go. Thanks<\/p>","upvoteCount":3,"answerCount":7,"datePublished":"2019-06-25T13:31:52.000Z","author":{"@type":"Person","name":"jonfollowell2","url":"https://community.spiceworks.com/u/jonfollowell2"},"acceptedAnswer":{"@type":"Answer","text":"
So I made a pivot with how I was making my script. The feedback here was helpful. Thanks for your time!<\/p>\n
Also yes it does work. I already see how I can vastly improve it and make it more efficient but for a first project I am happy.<\/p>\n
Till next time. Stay spicey.<\/p>","upvoteCount":0,"datePublished":"2019-06-26T18:27:25.000Z","url":"https://community.spiceworks.com/t/user-input-captured-incrementing-until-condition-met/718041/7","author":{"@type":"Person","name":"jonfollowell2","url":"https://community.spiceworks.com/u/jonfollowell2"}},"suggestedAnswer":[{"@type":"Answer","text":"
Hello All,<\/p>\n
I am just starting my voyage into Powershell and one of the things I am currently trying to do is write a Script to create a MS Team. I have created plenty of teams already from powershell but I want to make it so anyone in my team even student workers with no know how could just run my script.<\/p>\n
Capturing simple variables like the name, description, owner and such have been easy. The part I am trying to figure out is how to capture all of the members to be added.<\/p>\n
In my mind I see something roughly along the lines of this. I know it won’t work I just don’t know how to increment a user input variable until a condition is met and capture each as a unique variable that I can call later.<\/p>\n
$member = (read-host \"What is the email address of the member you want to add?\")\n$moreUsers = (read-host \"Do you want to add more users? Yes or No?\")\nwhile ($moreUsers -notlike \"no\")\n {\n increment something here on $member for capture\n $member2 = (read-host \"What is the email address of the member you want to add?\")\n $moreUsers = (read-host \"Do you want to add more users? Yes or No?\")\n }\n<\/code><\/pre>\nIf anybody could point me to a good primer on capturing user input like this that would increment until a condition would be met that would be great or give me a hand on making that butchered nonsense above into something working. Any tips are welcome. I am enjoying the flexibility with powershell but I have a long ways to go. Thanks<\/p>","upvoteCount":3,"datePublished":"2019-06-25T13:31:52.000Z","url":"https://community.spiceworks.com/t/user-input-captured-incrementing-until-condition-met/718041/1","author":{"@type":"Person","name":"jonfollowell2","url":"https://community.spiceworks.com/u/jonfollowell2"}},{"@type":"Answer","text":"
Welcome!<\/p>\n
If you post code, please use the ‘Insert Code’ button. Please and thank you!<\/p>\n