Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

Hey, Scripting Guy! How Can I Use the Do…While…Loop in Windows PowerShell?

(image) Hey, Scripting Guy! I frequently work with arrays in my scripts. The way I write scripts, I end up using Do…While…Loop frequently. I know that you like using the For…Each…Next for arrays, but to me Do…While…Loop seemed easier and more flexible. I looked and cannot find an example of how to use Do…While…Loop in Windows...

Hey, Scripting Guy! How Can I Use the Windows PowerShell Equivalent of the VBScript While…Wend Loop?

(image) Hey, Scripting Guy! I have been using VBScript for a long time. One of my favorite language statements in VBScript is the While…Wend loop. It is easy to use and easy to understand. Is there an equivalent command in Windows PowerShell?- HS(image) (image) Hi HS, WE never did use the While…Wend loop very much. WE generally used ...

Hey, Scripting Guy! How Can I Write and Run a Windows PowerShell Script?

(image) Hey, Scripting Guy! I appreciate the command-line stuff you are showing, but to be honest, I am not interested in returning to the DOS days to administer my network. I am not a UNIX administrator-I am a Windows guy. If I wanted to do UNIX kinds of things, I would download the latest *nix distro, obtain a silly haircut, grow facial ...

Hey, Scripting Guy! How Can I Work with Directories, Files, and Folders by Using Windows PowerShell?

(image) Hey, Scripting Guy! This may not sound too exciting, but I do a lot of work with files and folders. I constantly have to create folders and files, move files, and move folders. This was easy to do by using VBScript, but nevertheless it always required at least six lines of code to do anything. Is it possible to simplify this process ...

Hey, Scripting Guy! How Can I Identify and Delete an Instance of a Process?

(image) Hey, Scripting Guy! I want to do a query for a process, and if the process is running, I want to delete that process. I know I could write a script by using WMI, but is there something native to Windows PowerShell that I can use to find and to delete the process? Next question: what if there is more than one process I have to delete...