Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

How to Use For loop or while loop in powershell

$
0
0
Hi All i am new to powershell and trying to work around with for loop or while loop. I am using the following script

    $FirstName = Read-Host "Please Enter First Name"

    IF([string]::IsNullOrEmpty($FirstName)) {            
    Write-Host "First Name cannot be left blank Please enter first Name"            
    } else {            
    Write-Host "Your Name is" $FirstName            
    }
If the user does not enter any text i would like powershell to display message again for atleast 3 times to enter first name and than exits it. But dont know how to do it

Viewing all articles
Browse latest Browse all 15028

Trending Articles



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