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...
ps1
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...
Calling PowerShell from VBScript
Maybe you are happy with other scripting languages, like VBScript, and would like to stick to that for awhile. Still, you'd like to enhance your...
Launching Files with Arguments
Often, you want to submit additional arguments to a program file when you launch it, such as you want to open IE and have it navigate to some Web...
Launching Files with Spaces
What if you'd like to launch a file with spaces in its path? The first rule is that spaces are separators, so PowerShell would separate it at...
Launching Files without Specifying a Path
For security reasons, PowerShell launches files only when specified with a relative or absolute path name. The only exceptions to this rule are...
Launching Files
The most important rule: always specify either an absolute or relative file path to whatever you want to launch - except if the file is located in a...
Getting Real Paths
PowerShell uses virtual drives, which sometimes have a close mapping to the "real" drives you see in Windows Explorer. However, sometimes...
Deleting Things
To delete things in the file system, you normally use a command like "del", which is an alias and points to Remove-Item in PowerShell:...
Append Information to Text Files
Add-Content is a versatile command if you need to add additional content to text files. For example, you can create log file entries like this:...
Secret -Force Switch
PowerShell automatically displays all object properties when you output the object to the console. Here is an example: Get-WmiObject win32_bios...
Returning Exit Code from Script
When running a PowerShell script, you may want to return a numeric exit code to the caller to indicate failure or success. You should use the...