I am starting to learn Powershell and I have a csv file (pcfile.csv) with two columns:
- Column one: PC - PC1, PC2, PC3
- Column two: User - John, Michael, Tracy
I want to use test-path to check if the folder exists:
\\PC1\c$\users\John
\\PC2\c$\users\Michael
\\PC3\c$\users\Tracy
Here is my code
$PCs = import-csv c:\pcfile.csv | select -ExpandProperty PC
$Users = import-csv c:\pcfile.csv | select -ExpandProperty User
Foreach ($PC in $PCs) {
$Path = Test-Path "\\$PC\c$\$User"
If ($Path -eq $True) {Write-Host 'Folder exists'}
Else {Write-Host 'Folder does not exist'}
}
The problem I have is that I don't know how to put each user from $Users to check the path