I have only just stated learning PS and I want to create a folder path using variables.
This is the script
$root="C:\pstest\"
$folder=import-csv "C:\pstest\folder.csv"
Foreach ($directory in $folder){
write-host $root$directory
}
$folder outputs this
C:\Windows\system32> $folder
Directory
---------
AAAA
BBBB
CCCC
DDDD
CCCC
EEEE
GGGG
This is the csv
PS C:\Windows\system32> type C:\PSTest\folder.csv
Directory
AAAA
BBBB
CCCC
DDDD
CCCC
EEEE
GGGG
I want an output like
C:\pstest\AAAA
C:\pstest\BBBB etc
But what I get is
C:\pstest\@{Directory=AAAA}
C:\pstest\@{Directory=BBBB}
The aim is I have to verify the existence of a folder and if it doesn't exist create it. I worked out that bit but I want script is as I have to check 2500 folders the $root bit stays the same for all the folders so I was trying to shorten the code by using a variable and at the same time learn how to joining variables like this together