Hi,
As i mentioned earlier that i am very busy in the month on October and November that’s why i was not able to write any article on Powershell, but i am little free now and will try to publish articles whenever i get free time.
Today one of my fried call me and he was having some problem understanding DO WHILE loop, I explained the working of the loop over the phone to him and i thought it is worth writing a post on it.
the working of do while loop is simple.
do { code block }
while ( condition )
for example.
do { Dancing }
while ( music is playing )
You got an idea ? isnt ?
That means do something till while condition is true. Like in above not-IT example do the Dancing till the Music is Playing
In IT world we can use it in a various ways . Lets try this ….
and type the below in the powershell console.
- Do { Ping google.com } while ( Get-Process Notepad | Select-Object -Property Responding )
what is happening?
Powershell Will Ping Google.Com till the notepad windows is open.
You can notice our Notepad windows is open and we have constantly pinging Google.com and after 4 Pings it starts again.
I hope it is little bit clear now
Thanks
Aman Dhally