The “Hey, Scripting Guys!” blog has been retired. There are many useful posts in this blog, so we keep the blog here for historical reference. However, some information might be very outdated and many of the links might not work anymore.
New PowerShell content is being posted to the PowerShell Community blog where members of the community can create posts by submitting content in the GitHub repository.
(image)
Hey, Scripting Guy! Is there a good way to time how long it takes for a script to run? -- BN, Montreal, Canada
(image) (image) (image)
Hey, BN. Probably the easiest way to do this is to let the script time itself. To accomplish that feat, set the first line of the script to this:
This code simply sets the value of the variable ...
(image)
Hey, Scripting Guy! Is there an easy way to save my script output to a text file rather than displaying it on screen? -- KP, Ogden, UT(image) (image) (image)
Hey, KP. If you always want your script to save data to a text file rather than display it on screen, then you’re probably better off using the FileSystemObject and its file-...
(image)
Hey, Scripting Guy! I have a script which performs some file management tasks, and then should ask the user whether or not they want to delete a set of files. How do I ask a user a Yes or No question like this? -- SE, Casper, WY(image) (image) (image)
Hey, SE. There are a couple different ways that you can do this, but because you’...
(image)
Hey, Scripting Guy! Is there any way to have my script output copied to the Clipboard? -- ZW, Marseilles, France
(image) (image) (image)
Hey, ZW. Well, as long as you don’t mind crazy work-arounds then, yes, it’s actually pretty easy to copy script output to the Clipboard. To start with, you need to construct a string ...
(image)
Hey, Scripting Guy! I have a log file in which new data is appended to the bottom of the file; that means the most recent entries are at the end of the file. I’d like to be able to read the file starting with the last line and then ending with the first line, but I can’t figure out how to do that.-- MB, Milwaukee, WI
(...