Scripting Blog

A place to learn about PowerShell and share stories of automation

How Can I Correlate Logical Drives and Physical Disks?

Hey, Scripting Guy! How can I correlate logical drives and physical disks?-- LB Hey, LB. We’ll make a deal with you: we’ll show you a script that can tell you which logical drives are found on which physical disks, and you promise not to say, “Wait, I don’t understand how this script works.” To tell you the truth, we’re not so ...

How Can I Remove the Last Carriage Return-Linefeed in a Text File?

Hey, Scripting Guy! How can I remove the last carriage return-linefeed in a text file?-- LEK Hey, LEK. From the rest of your email you note that you’re using the FileSystemObject to read a text file, then using the contents of that text file as a query in another application. Unfortunately, though, the text file invariably has a carriage ...

How Can I Switch Between Using a Proxy Server and Not Using a Proxy Server?

Hey, Scripting Guy! At work we need to use a proxy server to connect to the Internet; when I take my laptop home to work, however, I don’t need to use a proxy server. I know I can use the Internet Options in Control Panel to change between using a proxy server and not using a proxy server; is there any way to switch between the two using a...

How Can I Generate Random Numbers Using a Script?

Hey, Scripting Guy! Our auditors have suggested that we randomly pick projects to examine and ensure that each project was completed and signed off per company policy. Because these projects are numbered sequentially I thought maybe we could write a script that would randomly select the project numbers for us to audit. Can you help us with ...

Hey, Scripting Guy! How Can I Access Active Directory on a Specific Domain Controller?

Hey, Scripting Guy! How can I access Active Directory on a specific domain controller?-- SD Hey, SD. You know, one of the cool things about Active Directory is that you usually don’t need to access the directory service on a specific domain controller. Because Active Directory information is replicated between all the domain ...