I want to use a variable for the path, instead of typing it manually
Instead of this
#create a folder
New-Item -Path 'D:\Test\New_folder' -ItemType Directory
to have something like this
$path='D:\Test'
#create a folder with a var
New-Item -Path '$path\New_folder' -ItemType Directory
But it is not working. I really appreciate any help you can provide.
CodePudding user response:
You just have to use double quotes "
to allow var to expend :
$yourPath='D:\Test'
New-Item -Path "$yourPath\New_folder" -ItemType Directory