When you assign a mandatory data type to a variable, then this will improve script robustness: whenever a value is (accidentally) assigned to that...
posts
Make Parameters Mandatory and Optional at the Same Time
An often overlooked feature in PowerShell is the ability to make a function parameter both optional and mandatory - at the same time. Let's for...
Enabling Visual Styles
When you use Windows Forms dialogs and windows, you may have noticed that they show differently, depending on whether you launched your script from...
Finding PowerShell Module Requirements
PowerShell modules extend functionality by adding more cmdlets and/or providers. Modules support copy-and-paste deployment...
Using ValidatePattern attribute
PowerShell can validate parameters using regular expressions. This example accepts only computer names that start with "PC" followed by...
Creating Script Blocks from Strings
Sometimes you may want to create a script block dynamically from a string. This could be necessary to include local variable content, for example....
Analyzing Script Blocks
Script blocks are simply pieces of PowerShell code. You probably use them all the time in scripts and functions. A script block is defined by braces...
Creating Simple Custom Dialog
PowerShell can display custom dialogs easily. So if you're not satisfied with the dialog buttons available in a standard MsgBox dialog, simply...
Getting Screen Information
Ever needed to know the current screen resolution or related screen information? Here's an easy way of getting that information: Add-Type...
Disassembling C# Code
Adam Driscoll, another PowerShell MVP, has published a function called Get-MemberBody to PoshCode: http://poshcode.org/4127. In conjunction with the...
Understanding Profile Scripts
Whenever you want PowerShell to configure or execute code automatically on launch, the code needs to go into one of four profile scripts. They...
Test Local User Account Credentials
Here is a snippet that verifies a local user account. Simply submit a username and a password. You get back either $true or $false: $username =...