Scripting Blog [archived]

Formerly known as the "Hey, Scripting Guy!" blog

Hey, Scripting Guy! How Can I Delete All the Files in a Folder Except for the Most-Recently Created File?

(image) Hey, Scripting Guy! I have a folder that has about 50 files in it. How can I delete all those files except the one most-recently created?-- GA(image) (image) (image) Hey, GA. You know, today would be a good day to review some of the items that have recently been in the news. (You know that life must be exceedingly dull for the ...

Hey, Scripting Guy! How Can I Search a Text File for Activities That Took Place on a Specified Date?

(image) Hey, Scripting Guy! I’m trying to write a script that can go through a log file and determine the number of users who logged off on a particular day. Can you help me?-- TM(image) (image) (image) Hey, TM. You know, when you work at Microsoft people think you probably come to work in your pajamas, ride a unicycle through the ...

Hey, Scripting Guy! How Can I Move Emails From One Outlook Folder to Another?

(image) Hey, Scripting Guy! You’ve had several articles that show how it’s possible to find specific email messages in Outlook; for example, you’ve shown us how to find all the emails sent by a particular person. What I was wondering is this: after you find these emails, is it possible to have the script move the messages to a ...

Hey, Scripting Guy! How Can I Determine the Distinguished Name of the OU Where the Logged-On User’s User Account Resides?

(image) Hey, Scripting Guy! As part of a logon script, I need to determine the distinguished name of the OU for the user logging on. How can I do that?-- LK (image) (image) (image) Hey, LK. Today is May 12th, which might not mean much to you. But, then again, maybe it does; after all, May 12this the birthday of Cosimo II de' Medici, Grand ...

Hey, Scripting Guy! How Can I Use Windows PowerShell to Pick Out the Unique File Extensions Used in a Collection of Files?

(image) Hey, Scripting Guy! I’m having a strange problem with Windows PowerShell, and I was wondering if you could help me solve it. I’m trying to get a list of the unique file extensions used by the files in a folder. I have a whole bunch of different file types in that folder, but every time I run my command it returns just one file ...