Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Do-While loop until input is null

$
0
0

Hello, I am trying to write a script to do something with user names that is entered in at the input.

$users = @() Do {$users += Read-Host "What is the username: "} until ($users -eq "")

I have that code so far, but the problem is, it doesn't exit until I hit 'ENTER' three times (so it gives 2 null values until it exits).

I viewed this thread: http://social.technet.microsoft.com/Forums/en-US/winserverpowershell/thread/cfb361d2-0868-414a-9b9c-6342df4437b1 , but I don't really understand the TRY/CATCH statement that's in there (that's marked as the answer) and if it's even needed for my use.

Thanks!


Viewing all articles
Browse latest Browse all 21975

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>