Powershell

Validating Variables

Variables and function parameters can be automatically validated through validation attributes. Here is a simple example making sure $test1 can only...

read more

Searching for ADUsers

The free Microsoft RSAT tools come with the PowerShell “ActiveDirectory” module: plenty of cmdlets help you administer Active Directory...

read more

ToString() Masquerade

In the previous tip we explained that ToString() is a fuzzy way of describing an object, and that the object author can decide what ToString()...

read more

Careful with ToString()

Any .NET object has a method ToString() that returns a text representation. This is also what you get when you output an object in a string....

read more

Bitwise Shift

PowerShell contains some binary operators that are not so commonly used, for example bitwise shifting. The -shl operator shifts bits to the left:...

read more

HTML Encoding Advanced

The static .NET method HtmlEncode does a good job encoding the usual character codes but fails with many special characters. To encode all...

read more

HTML Encoding

There is a static .NET method that you can use to HTML-encode text, for example if you want the text to display correctly in HTML output: PS>...

read more

Translating Error Records

Whenever PowerShell records an error, it wraps it in an Error Record object. Here is a function that takes such an error record and extracts the...

read more
1 43 44 45 46 47 130