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:pstestfolder.csv"
Foreach ($directory in $folder){
write-host $root$directory
}
$folder outputs this
C:Windowssystem32> $folder
Directory
———
AAAA
BBBB
CCCC
DDDD
CCCC
EEEE
GGGG
This is the csv
PS C:Windowssystem32> type C:PSTestfolder.csv
Directory
AAAA
BBBB
CCCC
DDDD
CCCC
EEEE
GGGG
I want an output like
C:pstestAAAA
C:pstestBBBB 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