The script in the ISE and the output from the script are shown in the following image: In the While evaluation block, I check to see if $a is less than or equal to 5. I print the current value of $a, and then close the script block. Next I display the value of $a, and then I increment $a. In the Do loop, I print a message that I am starting the loop. In the script that follows, I set the value of the $a variable to equal 1. Now I want to take a look at a real Windows PowerShell script that illustrates using the Do…While loop. } (While (weather –eq ‘sunny’) Using Do…While In Windows PowerShell script, it would look like the following: The strange thing is the way the evaluation goes. So I might go outside and ride my bike while the sun is shining. As an example, here is a recent weather forecast for Charlotte, North Carolina, where the Scripting Wife and I live: The whole idea is that I am going to do something while a condition exists. The Do…While loop construction in Windows PowerShell is a bottom evaluated version of the While loop that I talked about in PowerShell Looping: Using While. A "Scooby Do, where are you" kind of do? Probably not. Someone saw me and said, “What are you doing with coffee? Don’t you usually drink tea?” Well, yes I do, but I thought I would go for the "hard stuff" to provide a little extra jolt before my session.Īfter one of my sessions, someone came up to me and said they liked my blog posts last week, and wondered if I would write something about Do. But the energy was buzzing around and therefore, it was awesome.īefore one of my sessions, I decided to get a cup of coffee. I am talking about 16-hour days, and a three-hour time zone change kind of tired. We got to reconnect with many old friends, and we also made new ones. Last week, the Scripting Wife and I were at the Windows PowerShell Summit in Bellevue, Washington. Microsoft Scripting Guy, Ed Wilson, is here. Summary: Microsoft Scripting Guy, Ed Wilson, talks about using the Do…While statement in Windows PowerShell scripts.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |