Converting the FileSystemObject's BuildPath Method

Definition: Appends a name to a given path. Note that this doesn’t create a new subfolder, it creates only a path string. The backslash between portions of the path will be added automatically.


The Join-Path cmdlet performs this same task in PowerShell:

$new = Join-Path "C:\Scripts" -childpath "New Folder"

We’ve simply passed Join-Path a string with the first part of the path, and the name of the end of the path (specified with the -childpath parameter).

It’s also possible to simply concatenate strings to form a path, but you need to make sure to put in the correct backslash characters:

$new = "C:\Scripts" + "\" + "New Folder"

See conversions of other FileSystemObject methods and properties.
Return to the VBScript to Windows PowerShell home page