Scripting Blog

A place to learn about PowerShell and share stories of automation

How Can I Determine the Date for the Friday in a Given Week?

Hey, Scripting Guy! Given a date, can a script tell me the date that the Friday for that week occurs?-- DLR Hey, DLR. Too bad you didn’t ask which dates Saturdays, Sundays, and holidays fall on; coincidentally enough, each of the Scripting Guys have memorized - years in advance - all the days that we aren’t required to come to work. ...

How Can I Compare Two String Values Regardless of Letter Case?

Hey, Scripting Guy! I have a script that compares two email addresses and tells me whether or not they are the same. Sometimes the email addresses are the same, but the case is different: for example, one address might be example@abc.com and the other might be example@ABC.com. My script always tells me that these are different email ...

Hey, Scripting Guy! How Can I Retrieve the Value of an Active Directory Attribute that has a Hyphen in Its Name?

Hey, Scripting Guy! We have a custom application that adds some attributes to the Active Directory schema. These attributes have hyphens in their names, and I can’t figure out how to retrieve the value of those attributes; any time I try to connect to one I get an error message. Any suggestions?-- TW Hey, TW. You know a lot of people ...

How Can I Determine if a File Exists and, if It Does, Exit the Script?

Hey, Scripting Guy! How can I check to see if a particular file exists and, if it does, exit the script?-- TO Hey, TO. There are at least two ways to check for the existence of a file (that’s the real key here; exiting the script is easy). One of these approaches uses the FileSystemObject and the other uses WMI, and we’re going to show ...

How Can I Show Users a Dialog Box That Only Lets Them Select Folders?

Hey, Scripting Guy! In previous columns you’ve shown us how to present users with a dialog box that enables them to select files. Is there any way to show them a dialog box that only lets users select folders?-- LP Hey, LP. You know, you’ve come to the right place: the Scripting Guys have just what the doctor ordered. Actually, we have ...

Feedback usabilla icon