With New-Item, it is easy to create new registry keys: New-Item HKCU:SoftwareTestkey New-Item can only create one key at a time and fails if the...
database-tools
Virtual Drives With UNC-Paths
With New-PSDrive, you can create new virtual PowerShell drives to locations you often visit. New-PSDrive needs three pieces of information: the name...
Assigning Values to Parameters
Cmdlets and Functions most of the time support one or more parameters. Let's take this simple function. It defines two parameters called number and...
Avoid Format-… in Scripts
The family of Format-... Cmdlets is useful for outputting data into the console. You probably often used lines like this: Get-Service | Format-Table...
Using Switch Parameters
Switch parameters work like a switch, so they are either "on" or "off" aka $true or $false. To add a switch parameter to a...
Conflicting Commands
PowerShell supports many different command categories and searches for the command in the following order: 1. Alias 2. Function 3. Cmdlet 4....
Extending Alias Functionality
Alias names are a good way of making commands more accessible. The following line would enable you to quickly launch Internet Explorer by entering...
Finding Alias Names
To find out all alias names associated with a given command, filter the alias list by its definition property. The following command lists all...
Trustworthy Folders
If you want to launch a script file or executable, in PowerShell, you'll need to specify either a relative or absolute pathname. To do so by...
Removing Illegal File Name Characters
If you have to batch-process tons of file names, you may want to make sure all file names are legal and automatically remove all illegal characters....
Removing Illegal Path Characters
You can always strip all illegal characters from the path If you have no time to review path names and correct them manually to see if they...
Using Test-Path to Validate A Path
While raw .NET calls provides you with granular control over how to validate paths and file names, there is a cmdlet called Test-Path for simple...
Checking File Names for Invalid Characters
File names may not contain certain characters because they are illegal and cannot be processed by Windows. First, let's find out which...
Checking Paths for Invalid Path Characters
Paths may not contain certain characters because they are illegal and cannot be processed by Windows. First, let's find out which characters are...
Using Advanced Path Functions
Whenever the built-in Split-Path cmdlet isn't enough, you can always resort to the real .NET class behind it. This class is called...
Using Simple Path Functions
PowerShell comes with the Split-Path cmdlet, which helps you disassemble paths and find the interesting information. Take a look: Split-Path...
Using VB.NET to Migrate From VBScript
If you have ever written scripts using VBScript and now are trying to migrate them to PowerShell, you may miss a lot of useful commands not...
Casting Strings
Strings represent text information and consist of individual characters. By casting, you can convert strings to individual characters and these into...
Using String Functions
PowerShell uses .NET objects everywhere. Anything is represented as .NET object, and .NET objects come with useful built-in methods. However, for...
Processing External Script Output in Real Time
In a previous tip, you learned how to call an external VBScript from PowerShell and read back any text VBScript returned. We will now take a look at...
Returning Text Information from VBScript To PowerShell
Sometimes, you may want to recycle old and proven VBScript scripts and call them from within PowerShell. In a previous tip, you have learned how to...
Calling VBScript From PowerShell
Sometimes, you may have an existing VBScript that already does just what you want. You can easily incorporate any VBScript into PowerShell because...
Returning Text Information From PowerShell To VBScript
In a previous tip, you learned how to call PowerShell statements and read their return value. Return values are somewhat limited because they can...
Reading PowerShell Return Values From VBScript
It is easy for VBScript to call a PowerShell script as you have learned in a previous tip. PowerShell can even return a numeric value so your...