Scripting Blog

A place to learn about PowerShell and share stories of automation

How Can I Run a Script Against a Range of IP Addresses?

Hey, Scripting Guy! I’d like to run a script against all the computers on a subnet. Is there a way to do that without having to hardcode all the IP addresses into the script?-- RB Hey, RB. Based on your email, it sounds like you have a setup similar to this: you have a subnet with IP addresses ranging from 192.168.1.1 to 192.168.1.254. ...

How Can I Pause a Script and Then Resume It When a User Presses a Key on the Keyboard?

Hey, Scripting Guy! I would like to be able to pause my script, then have it resume as soon as the user presses any key on the keyboard. How do I do that?-- AL Hey, AL. Boy, this question takes us back: “Press any key to continue,” along with “Abort, Retry, or Fail,” has to be one of the most famous phrases in computing history. ...

Can I Change the Command Window Title When Running a Script?

Hey, Scripting Guy! When I run a batch file, I can use the Title command to change the caption of the command window. Can I change the caption of the command window from within a script?-- AA, Yokohama, Japan Hey, AA. Well, yes, as long as you’re willing to open up a new command window. If you are, then you can use code similar to this:Set ...

Can I Change the Current Directory When Running a Script?

Hey, Scripting Guy! Can I change the current directory while my script is running?-- KO, Kalispell, MT Hey, KO. Yes, you can change the current directory while a script is running, provided you are running Windows Script Host 5.6, that is. To change the current directory, all you have to do is create an instance of the Wscript.Shell object, ...

How Can I Call the Dir Command?

Hey, Scripting Guy! I’m trying to do something that seems pretty simple: call the dir command from a script. It doesn’t seem to work, though. How come?-- CR, Mexico City, Mexico Hey, CR. It appears from your mail that you’re trying to do a simple thing like this:Set objShell = CreateObject("Wscript.Shell") objShell.Run("dir"), 1, TRUE ...