Twitter

Categories

PowerShell

Finetuning screen brightness with PowerShell

When I work in a low-light environment I like to have fine-grained control over the brightness of my monitor. When I change the brightness using the special function keys on my keyboard, it changes in steps of 10%! That’s a lot. PowerShell to the rescue!

PowerShell

Generate XML with attributes using PowerShell

Today I discovered that generating XML with PowerShell isn’t as straight forward as I had hoped. I started off with a CSV that I had to convert to XML. Fortunately PowerShell is very good when it comes to CSV. It was the parsing of the object to XML-attributes that proved the most challenging part.

Automation, PowerShell, Windows

PowerShell snippet: check if software is installed

Some deployment scripts need to check if certain required software is installed on a Windows Machine. You could check if the file is present at a certain location, but there is a better way to check if software is installed: the uninstall database in the Windows Registry. PowerShell makes it really easy to query the registry!

PowerShell

Create mp3 playlist with PowerShell

Playlist are a dandy way of organizing the files into one list (easy to find on your device). The m3u playlist format is a no-hassle straight forward format, that’s why I love it. It is basically a list of relative file paths. Well… if it is that simple, it should be easy to write into a PowerShell statement.

PowerShell

Comparing files with PowerShell

Sometimes you want to test if two files are the same. You could run MD5 or SHA hashes of the files, but it might take some time to compute them. A byte by byte comparison might be the faster instead. I’ve wrote a script doing it in PowerShell.

PowerShell

Regex Replacement Problem PowerShell: $1?

Madre mia! I’ve been trying to edit an HTML file using PowerShell. I only wanted to eliminate all the spans and paragraphs using regular expressions (would make sense)… and how hard can that be?
Well, it turned out to be pretty hard if you’re used to the replacement syntax of regular .Net expressions! After searching for hours I’ve discovered that $1 can’t be used in the same way as in .Net. Just use ${1}. Ouch!

©2010-2019 by Kees C. Bakker, all code is licensed under MIT.
By using our website, you hereby consent to our Privacy Policy and agree to its Terms and Conditions.