Starting to learn Powershell, 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 I don't know how to put each user from $Users to check the path
https://stackoverflow.com/questions/67309569/test-path-in-powershell-using-data-from-multiple-columns-in-a-csv-file April 29, 2021 at 08:33AM
没有评论:
发表评论