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 ….
![13-12-2012 15-18-38 13-12-2012 15-18-38](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjLJ_xtzayGSfyUj0f4IJWvfXDWkJ9Eur5FaMKYQMNnjxPf13MRpBOV4kLHYfHlUcd7-VfZz3SyqqG1NCUHVSbyJFPFRzS1E4TapJ1kqvJAaT__KFEE139Nqin12DDxN6AlhffiHZ4XKBJJ/?imgmax=800)
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
![follow aman on Twitter follow aman on Twitter](https://lh3.googleusercontent.com/blogger_img_proxy/AEn0k_t5myjlisEVnHUsapINp8pG7fRZSSyGdOItRMxMdW--XiWs5jbFobmNiSQBYaaLxPTuCnhql_8FfT2xmVU9iBdNgs40JbAvl0cSnvOMcbTd1wKpW8LedxpYkQpf3NzJCACP4LFzjiE9xoeX6qP5kPWtqsQV3j8omKaV8W0X5Js=s0-d)