database-tools

Casting Data with Culture

When casting data (converting it to a different data type), PowerShell supports two approaches that can differ considerably. Here is an example:...

Invoking a Script Block

Code inside a script block can either be invoked by call operators such as „&“ or „.“, or by calling the Invoke()...

Running Cmdlets without Verb

This has been part of PowerShell since version 1.0: cmdlets with verb „get“ can be invoked without the verb. So instead of...

Texts with Maximum Length (Part 2)

Here is another strategy to make sure a text does not exceed a given length. In contrast to our previous tip, this code will not pad spaces in case...

Finding All Profiles with Desktop

This simple line dumps all paths to all desktops found in any of the local user profiles – just make sure you are running the line with...

Where-Object and .Where()

Beginning in PowerShell 4, you can use the Where() and Foreach() methods in place of Where-Object and ForEach-Object whenever you do not want to use...

Creating Object Arrays on the Fly

Here is a quick code sample that generates an array of objects using the built-in CSV parser: $csv = @' PC,Date PC82012,2017-02-28...

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

1 72 73 74 75 76 159