Powershell

Exploring Type Accelerators

PowerShell uses a number of so-called type accelerators that help with long .NET type names. Instead of using...

Dangerous Temp Files!

Internal system functions are often helpful, but always make sure you fully understand what they do. A particularly popular system method is called...

Explore Objects

In PowerShell, anything is represented by objects, and here is a helpful one-liner that examines any object and copies its members as text into your...

Managing Bit Flags (Part 4)

In PowerShell 5, the new support for enums makes dealing with bit values much easier as you’ve seen in previous tips. Even setting or clearing...

Managing Bit Flags (Part 3)

Setting or clearing bit flags in a decimal is not particular hard but unintuitive. Here is a quick refresher showing how you can set and clear...

Managing Bit Flags (Part 2)

In the previous tip we illustrated how you can use PowerShell 5’s new enums to easily decipher bit flags, and even test for individual flags....

Managing Bit Flags (Part 1)

Occasionally, you might have to deal with bit flag values. Each bit in a number represents a certain setting, and your code might need to determine...

Working With Generics

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...

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...

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:...

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 “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...

1 36 37 38 39 40 104