Scripting Blog

A place to learn about PowerShell and share stories of automation

How Can I Tell Whether a Logon Script is Running on a Workstation or on a Server?

Hey, Scripting Guy! How can I tell whether a logon script is running on a workstation or on a server? If the script is running on a server, I want to skip a portion of the script.-- RT Hey, RT. You know, a few years ago one of the Scripting Guys helped a fellow Microsoft employee set up a computer lab that this other Microsoft employee ...

How Can I Get Total Size and Number of Items in an Office Outlook Folder?

Hey, Scripting Guy! How can I get the total number of items - and the total size - of all the items in my Inbox and Sent Items folders?-- CS Hey, CS. You know, one of the Scripting Guys has a foolproof method for determining this information. What does he do? Nothing; instead, he just sits around and waits for the inevitable email from the ...

How Can I List All the Sub-OUs in an OU?

Hey, Scripting Guy! How can I list all the sub-OUs in an OU? That includes any OUs that might be in those sub-OUs.-- JE Hey, JE. If you’re the least bit familiar with this column then you know that we Scripting Guys love to answer questions that involve searching Active Directory. That’s because we never bother to write detailed ...

How Can I Determine Which Day of the Year a Date Falls On?

Hey, Scripting Guy! How can I determine which day of the year a date falls on? For example, March 2, 2006 is the 61st day of the year.-- TW Hey, TW. You know, we almost feel guilty about answering this question. Why? Well, after all, we can answer it by writing just one line of code:Wscript.Echo DatePart("y", "3/2/2006") Note. So if ...

How Can I Take Ownership of a File or Folder By Using a Script?

Hey, Scripting Guy! How can I take ownership of a file or folder using a script?-- RV Hey, RV. Interesting question. In the past, the Scripting Guys have tried to take ownership of a Porsche 911, beachfront property in Hawaii, and the New York Yankees; all of those efforts failed. Considering our track record, we weren’t sure what would ...

Feedback usabilla icon