Generic types can use placeholders for actual types, and you may be wondering why that can be exciting. There are a number of data types, for...
powertips
Inheriting Classes in PowerShell 5 (part 2)
Here is another use case for the new class feature in PowerShell 5. In the previous example, we illustrated how you can derive new classes from...
Inheriting Classes in PowerShell 5 (part 1)
PowerShell 5 comes with built-in support for classes. You can use this new feature to enhance existing .NET classes. Here is an example: let’s...
Show or Hide Windows
PowerShell can call internal Windows API functions, and in this example, we’d like to show how you can change the show state of an application...
Using Pester Tests to Test Anything
Pester is an open source module shipping with Windows 10 and Windows Server 2016, and can be downloaded from the PowerShell Gallery...
Reading Environment Variables Freshly
When you read environment variables in PowerShell, you probably make use of the “env:” drive. This line retrieves the environment...
Setting Environment Variables
When setting environment variables through the PowerShell “env:” drive, you are always just manipulating the process set. It applies to...
Checking Host
In the past, Microsoft shipped two PowerShell hosts: the basic PowerShell console, and the more sophisticated PowerShell ISE. Some users used code...
Playing with PowerShell 6.0
PowerShell is open source now, and the next big release of PowerShell is being developed in the open. If you’d like to take a peek preview,...
Caching Credentials Using JSON
When you need to cache logon credentials to a file, this is typically done by piping the credential to Export-Clixml which produces a rather lengthy...
Free Guides to Start With PowerShell
If you have colleagues that don’t know PowerShell, and you would like them to get started, here are three free learning resources:...
Identifying Problematic Execution Policy Settings
PowerShell uses execution policy to determine which scripts to run. There are in fact five scopes where execution policy can be defined, and to see...
Checking Execution Policy
Execution policy determines what kind of scripts PowerShell will execute. You need to set execution policy to something other than Undefined,...
Classes (Static Members – Part 6)
Classes can define so-called “static” members. Static members (properties and methods) can be invoked by the class itself and do not...
Using Classes (Constructors – Part 5)
Classes can have so-called constructors. Constructors are methods that initialize a new object. Constructors are simply methods that share the name...
Using Classes (Overloading – Part 4)
Methods in classes can be overloaded: you can define multiple methods with the same name but different parameters. This works similar to parameter...
Using Classes (Adding Methods – Part 3)
One of the great advantages of classes vs. [PSCustomObject] is their ability to also define methods (commands). Here is an example that implements a...
Using Classes (Initializing Properties – Part 2)
Class properties can be assigned a mandatory type and a default value. When you instantiate an object from a class, the properties are pre-populated...
Using Classes (Creating Objects – Part 1)
Beginning in PowerShell 5, there is a new keyword called “class”. It creates new classes for you. You can use classes as a blue print...
Using “Using Namespace”
Working with .NET type names can be tiring because these names can be long. Here is an example: #requires -Version 2.0 Add-Type -AssemblyName...
Determining Person Age
How do you calculate the age of a person, based on birthday? You can subtract the current time delivered by Get-Date from the birthday, but the...
Speeding Up New-Object Synthesizer
New-Object creates new instances of objects, and you have seen one example in the past “Speech Week”: PowerShell was able to create a...
Speech-Week: Using Advanced Speech Synthesizer Options Synthesizer
The .NET speech engine accepts more than just plain text. If you use SpeakSsml() instead of Speak(), you can use XML to switch languages, speak...
Speech-Week: Recording Voice to File Synthesizer
The built-in Microsoft text to speech engine can save audio to a file. This way, you can auto-generate WAV files. Here is an example: it creates a...