Scripting Blog

A place to learn about PowerShell and share stories of automation

Hey, Scripting Guy! How Can I Import a Fixed-Width Data File into Microsoft Excel?

Hey, Scripting Guy! How can I import a fixed-width data file into Microsoft Excel?-- RS Hey, RS. This column is being written on a Friday morning, and so far it’s been a very weird morning at that. For one thing, it’s not raining and – if you look closely – you can even see the sun. (It’s been awhile, but we’d recognize the sun ...

Hey, Scripting Guy! How Can I Remove Duplicate Values From a Pair of Text Files?

Hey, Scripting Guy! I have two text files that contain numbers. I need to write a script that can determine whether a given number exists in both of these text files. If it does, I need to delete that line from each of the two files. How do I do that?-- KT Hey, KT. Before we get started today, we have a little business to take care of. ...

How Can I Replace Null Values in an Array?

Hey, Scripting Guy! How can I loop through a 12x12 array and replace any null values with a hyphen?-- AM Hey, AM. Sorry for the delay in getting back to you; as it turns out, yesterday was Independence Day (more typically referred to as the Fourth of July) in the good old USA, and the Scripting Guys, along with their fellow Microsoft ...

Hey, Scripting Guy! How Can I Get a List of All the Subfolders in a Folder and Then Put That List Into an Array?

Hey, Scripting Guy! How can I get a list of all the subfolders in a folder and then put that list into an array?-- PW Hey, PW. We know how anxious you’ve all been, waiting to hear whether the Scripting Guys were successfully moved from Building 43 to Building 42 (yes, directly across from their old building). Well, about the best we ...

How Can I Delete Duplicate Items From an Array?

Hey, Scripting Guy! How can I delete duplicate items from an array?-- WR Hey, WR. You know, if Microsoft has a weakness – and we’re not saying that it does, we’re just saying if it does – it’s this: we never make mistakes. (What’s that? What about Windows ME? That’s a weird name; couldn’t possibly be one of our products.) ...