Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

create multiple directories

$
0
0

Hello all,

i have this simple four lines script:

 $rootdir = "D:\"
 foreach ($folder in @("folder1", "folder2", "folder3")) {
  if (-not (test-path -path '$rootdir\$folder')){
     New-Item $folder -type directory
     }
     }

 

It is working but not exactly correct, or it is working exactly as it is supposed to work  since i have not concatenated my -path correctly :)

Folders are created under  C:\Users\Administrator

Can someone help me  here. How should i change the -path so three directories are created under D:\

 

Thanks a lot


Viewing all articles
Browse latest Browse all 6937

Trending Articles