Scripting Blog

A place to learn about PowerShell and share stories of automation

How Can I Change a User’s Password?

Hey, Scripting Guy! How can I change a user’s password using a script?-- GO Hey, GO. You didn’t indicate whether you wanted to change the password for a local user or for an Active Directory user. But that’s OK: the processes are so similar we’ll go ahead and show you how to do both. It’s like getting two Hey, Scripting Guy! ...

How Can I Determine if My Users Have Certain Files on Their Computers?

Hey, Scripting Guy! Is it possible to search a computer for .MP3 files or other files my users aren’t supposed to have?-- AK Hey, AK. Once again it’s WMI to the rescue. Using the CIM_DataFile class it’s easy to search a computer for specific file types. Want to know if your users have any .MP3 files lying around? Then just use a ...

How Can I Determine the Percentage of Free Space on a Drive?

Hey, Scripting Guy! I know how to determine the amount of free space on a drive, but how can I determine the percentage of free disk space on a drive?-- MS Hey, JP. You’re right: determining the amount of free disk space on a drive is pretty easy. For example, this simple little script tells you the amount of free space (in bytes) for ...

How Can I Count the Number of Lines in a Text File?

Hey, Scripting Guy! How can I count the number of lines in a text file?-- MS Hey, MS. It’s easy to tell that Microsoft’s scripting technologies weren’t written by people who do system administration for a living. Our scripting technologies are jam-packed with features and capabilities, yet we always seem to missing the things that ...

How Can I Automatically Run a Script Any Time a File is Added to a Folder?

Hey, Scripting Guy! Is it possible to have a script automatically run any time a file is added to a specific folder?-- MB Hey, WM. Yes, this is possible, thanks to the magic of WMI events, which allow you to write a script to monitor for something of interest (like a file being added to a folder) and then take some action any time an event ...