database-tools

Hiding Variable Content

When you override the ToString() method of an object you control how this object is displayed. The object content stays untouched, though: $a = 123...

Simple Replacement for INI Files

If you'd like to keep settings outside of your script and store them in a separate config file, then you can use all kinds of data formats for...

Remove Array Elements

Did you ever need to compare two arrays? Compare-Object might help. Check this out: $array1 = 1..100 $array2 = 2,4,80,98 Compare-Object...

Quickly Getting IP Addresses

You want to quickly get a list of IP addresses for your own computer or a network machine? Here is how: #requires -Version 3 $ComputerName =...

Shortening Text

Let's assume you want to chop off some text at the end of a string. This is the traditional approach using string operations: $text = "Some...

Avoid Using Redirection

While you can still use the old redirection operator to write command output to a file, you should rather use PowerShell cmdlets instead. Here is...

Encode PowerShell Commands

When you need to run code as a PowerShell command in a separate powershell.exe, it is not always safe to submit the code. Depending on from where...

Define Multiline Text

When you need to define multiline text, in PowerShell you typically use here-strings like this: $text = @" I am safe here I can even use...

Current Script Path

In PowerShell 1.0 and 2.0, you needed a lot of weird code to find out the current script location: # make sure the script is saved and NOT...

Discovering Dynamic Parameters

In a previous tip we showed how you find cmdlets that expose dynamic parameters. Let's explore what the dynamic parameters are. The function...

Finding Cmdlets with Dynamic Parameters

Some cmdlets expose dynamic parameters. They are valid only in certain contexts. Get-ChildItem, for example, exposes -File and -Directory only when...

Change ISE Zoom Level

The PowerShell ISE sports a zoom slider at its lower right edge, and you can control this slider with PowerShell code. So you could set defaults for...

Unzipping ZIP Files

In PowerShell 5.0, there is a new cmdlet that can unzip ZIP files: #requires -Version 5 $Source = 'C:\somezipfile.zip' $Destination =...

Testing a Network Port

To see whether you can access a remote computer via a given network port, here is a test function called Test-Port; it takes a remote computer name...

Finding Logged On Users

In a previous tip we explained how you find the physically logged on user. In this tip you will see how you can list the current logon sessions,...

Find Physically Logged On User

There can always be only one physically logged on user on a machine. The physically logged on user is the one sitting right at the machine. Here is...

Getting SQL Server Connection String

If you’d like to contact an SQL Server database via PowerShell, you need a connection string. The connection string contains all pieces of...

1 90 91 92 93 94 159