Using a drive letter in a path to the PowerShell New-Item command

Viewed 1102

This creates a new directory as expected:

new-item "c:\newdir" -itemtype directory

This also works:

$arr = "one", "two"
$arr | new-item -name {$_} -itemtype directory

Resulting in two new folders: c:\one and c:\two (assuming current directory is c:).

This fails with the error "The given path's format is not supported."

$arr = "c:\one", "c:\two"
$arr | new-item -name {$_} -itemtype directory

How can I make this work with a drive letter in the path?

3 Answers
Related