Scripting Blog

A place to learn about PowerShell and share stories of automation

How Can I Display a Hyperlink in a Message Box?

Hey, Scripting Guy! Is it possible to have a hyperlink to a Web page in a message box?-- CB Hey, CB. Sounds like you want to display a message box to users and, ideally, you’d like to include a hyperlink they could click on for more information. For example, suppose a user tried to access some resource and was turned away. In a case like ...

How Can I Determine the OU a User Account Belongs To?

Hey, Scripting Guy! How do I determine the OU a user account belongs to?-- CO Hey, CO. Ah, yes: the OU a user belongs to. No doubt a lot of you are thinking, “Well, there’s probably an OU property of some kind in Active Directory that gives you that information. All you have to do is locate the user account, and then get the value of ...

How Can I Get a List of All the Files in a Folder and Its Subfolders?

Hey, Scripting Guy! How can I use a script to show me all the files in a folder? And then how can I modify that script so it shows me all the files in any subfolders of that folder?-- CS Hey, CS. Yesterday we showed everyone a script that changed all the files in a folder from read-only to read-write. We also promised that, in today’s ...

How Can I Change a Read-only File to a Read-write File?

Hey, Scripting Guy! How can I change a read-only file to a read-write file?-- WR Hey, WR. We don’t mean to shock you, but how can you change a read-only file to a read-write file? Why, by using a script, of course! We know: you never saw that coming, did you? As a matter of fact, you can use this script, which changes the file C:\Scripts\...

How Can I Pick Out and Save Specific Lines in a Text File?

Hey, Scripting Guy! I’d like to be able to read through a text file, select the lines that begin with a particular word (like Failure), and then save only those lines back to the same text file. Is there any way to do that?-- AC Hey, AC. Hey, AC. For simplicity’s sake, we’re assuming you have a text file that looks similar to this:...