Test-path to my floor machines to make sure the destination is true and then after moving the file testing if the file exists. How can I get this to come out so the second half has true or false?
If i run them separate I get an output.
PS C:\Users\amandaw.QPC> Get-Content C:\apps\currentcomputers.txt | `
Select-Object @{Name='ComputerName';Expression={$_}},@{Name='ItemExist';Expression={ Test-Path "\\$_\c$\apps\$file"}}
ComputerName ItemExist
------------ ---------
Commercial1 True
TC-15 True
Floor03 True
Floor04 True
Mixit-PC True
TC2018B True
FLOOR07 True
tc2017p True
Floor09 True
TC2017k True
tc2017g True
ptc-6 True
tc2017a True
tc2017b True
Floor15 True
tc2019z True
tc2019b True
# path to Item to be copied
$item = "C:\Workstation\Pictures\pngtree___material_distribution_939546_1MJ_icon.ico"
#item
$file = "pngtree___material_distribution_939546_1MJ_icon.ico"
Get-Content C:\apps\currentcomputers.txt | `
Select-Object @{Name='ComputerName';Expression={$_}},@{Name='PathExist';Expression={ Test-Path "\\$_\c$\apps"}}
(copy the files- left out since don't need help with that)
Get-Content C:\apps\currentcomputers.txt | `
Select-Object @{Name='ComputerName';Expression={$_}},@{Name='ItemExist';Expression={ Test-Path "\\$_\c$\apps\$file"}}
Output...
PS C:\Users\amandaw.QPC> C:\Workstation\Documents\WindowsPowerShell.batch\Untitled5.ps1
ComputerName PathExist
------------ ---------
Commercial1 True
TC-15 True
Floor03 True
Floor04 True
Mixit-PC True
TC2018B True
FLOOR07 True
tc2017p True
Floor09 True
TC2017k True
tc2017g True
ptc-6 True
tc2017a True
tc2017b True
Floor15 True
tc2019z True
tc2019b True
Commercial1
TC-15
Floor03
Floor04
Mixit-PC
TC2018B
FLOOR07
tc2017p
Floor09
TC2017k
tc2017g
ptc-6
tc2017a
tc2017b
Floor15
tc2019z
tc2019b