Here's a code snippet that creates DateTime ranges. Just specify a year and a month, and the script produces a DateTime object for each day in...
Powershell
What Is Going On Here?
Frequently, you will have PowerShell retrieve data, and then you pick parts of the information and use it in reports. Like here: $serial =...
Password Obfuscator Script
Ever had the need to store a password in a script? Ever needed to automate a credential dialog? First: storing passwords and other confidential...
Encoding a Love Letters (and Other Things) in Hex Strings
If your partner is as geeky as you, he or she may enjoy a private message in hex encoding. Everyone else may at least enjoy the technology used...
Checking Disk Partitions and Block Size
WMI is a treasure chest full of information. This line will read local partitions along with their block sizes: Get-WmiObject -Class...
Converting Excel CSV to UTF8
When you export Microsoft Excel spreadsheets to CSV files, Excel by default saves CSV files in ANSI encoding. That's bad because special...
Finding All PowerShell Profile Scripts
Sometimes it can get confusing which startup scripts run when PowerShell starts. There can be plenty, and they may be different, depending on...
Creating Objects with CSV
There are many ways to create custom objects. Here's a creative solution that can be useful in many scenarios: create a text-based...
Finding Scripts by Keyword
With an increasing number of PowerShell scripts on your hard drive, it can become hard to find the script you are looking for. Here's a helper...
Setting Monitor Brightness
If your display driver supports WMI, then you can change the display brightness using PowerShell - event on remote machines! Here's the...
Check Monitor Brightness
If you want to check your current display brightness (preferably on notebooks, of course), here's a quick function: function...
Creating Symbolic Links
Symbolic links work very similar to "regular" link files (*.lnk): they can point to virtually any file or folder and even UNC paths....
Testing Administrator Privileges
To test whether a script is run by an Administrator with full privileges (UAC elevated), here is an unusual approach that illustrates the enormous...
Creating Hard Links
Hard links are file "phantoms" in the NTFS file system. They make one file visible in multiple file system locations (within one volume)....
Showing Hidden Files in File Explorer
PowerShell can easily read and write to the Registry, the central store for Windows settings. Here's a function that can turn the display of...
Verbose Output for PowerShell Functions
To add on-demand verbose output to your PowerShell functions, make sure your functions support the common parameters by adding the CmdletBinding...
Copying Results to Clipboard
To easily copy cmdlet results to other applications, simply pipe them to clip.exe. Next, paste the results into whatever application you want:...
Turn Out-GridView into Selection Dialog
Finally, in PowerShell 3.0, Out-GridView can turn into a versatile selection dialog - just add the new parameter -PassThru and watch: $Title =...
Three Most Useful ISE Tricks
If you use PowerShell 3.0 and the ISE editor, then here are the three most useful tricks you should know: 1. Press CTRL+J to open a list of...
Vertical Grid View
You can always pipe objects to Out-GridView and get a nice extra window with all of the object properties lined up as table. That's useful if...
Go to Function Definition on F12
If you are into writing long and complex PowerShell code with a lot of functions, then this one is for you. In other development environments, when...
Adding New Type Accelerators in Powershell
If you find yourself using certain .NET types frequently, you may want to make your life easier and implement shortcuts. For example, there is a...
Finding Type Accelerators
PowerShell maintains a list of shortcuts for .NET types to make coding more convenient for you. For example, to convert a string to a DateTime type,...
Returning Multiple Values
A PowerShell function can return multiple values. To receive them, simply assign the result to multiple variables: function Get-DateTimeInfo { #...