I’d like to create a folder based on a parameter used in the name, so for example:
$Website = "test"
new-item \\172.1.1.1\C`$\Folder\$Website_Archive -type directory
The _Archive needs to be part of the folder name but I cannot figure out how to pass the $Website with the _Archive included.
Here is the error I get:
New-Item : Item with specified name \172.1.1.1\C$\Folder\ already exists.
At line:2 char:9
+ new-item <<<< \172.1.1.1\C`$\Folder\$Website_Archive -type directory
+ CategoryInfo : ResourceExists: (\172.1.1.1\C\Folder\:String) [New-Item], IOException
+ FullyQualifiedErrorId : DirectoryExist,Microsoft.PowerShell.Commands.NewItemCommand
If I remove the ‘_Archive’ from the line it will create the folder named “test”. I’m assuming it’s looking for a parameter of $Website_Archive and not finding it so it tries to just recreate the root folder. How can I get the parameter passed into the folder name?
Thanks!
BB
Just escape the underscore with a backtick