Scripting Blog

A place to learn about PowerShell and share stories of automation

How Can I Search a Text File for 9-Digit Numbers?

Hey, Scripting Guy! How can I search for user names in a text file? In my case, the user names all consist of 9 digits, although they can be any 9 digits.-- GG Hey, GG. Interesting question. You want to search for 9-digit numbers (like 123456789) in a text file; the only problem is that these could be any 9-digit numbers. And that ...

How Can I Display a Multi-Valued Attribute Returned from an Active Directory Search?

Hey, Scripting Guy! How can I display a multi-valued attribute that I get back when using ADO to search Active Directory?-- ES Hey, ES. For the most part Active Directory is a script writer’s paradise; with very few exceptions anything you can do using the Active Directory snap-ins and GUI tools you can also do using a script. Of course, ...

How Can I Eliminate Duplicate Names in a Text File?

Hey, Scripting Guy! I have a text file that contains a bunch of names. How can I read through that text file and eliminate all the duplicate names?-- MW Hey, MW. We’re assuming you have a text file that looks something like this:Ken Myer Dean Tsaltas Jonathan Haas Ken Myer Dean Tsaltas Syed Abbas Gail Erickson Carol Phillips Dean Tsaltas ...

Hey, Scripting Guy! How Can I Bind to a User Account Using Something Other Than the CN Attribute?

Hey, Scripting Guy! Can I bind to an Active Directory account using the user’s mailNickname or their sAMAccoutName, something other than the CN?-- MB Hey, MB. When you bind to an account in Active Directory, you need to pass GetObject the account’s ADsPath. That means you need to use a line of code similar to this: The ADsPath ...

How Can I Insert a Column into a Spreadsheet?

Hey, Scripting Guy! How can I insert a column into an Excel spreadsheet?-- HE Hey, HE. Let’s assume you have a spreadsheet that looks something like this: And, yes, it is a very nice little spreadsheet, except for one problem. As you can see, we goofed, and we forgot to insert Dataset 3; instead, we only have Datasets 1, 2, and 4. Even ...

Feedback usabilla icon