Please educate me. I am trying to test if a file exists on a group of computers' desktop. Some computers are Windows 7 and some are Windows XP. When I run the code, It doesn't test the path on every computer and returns every computer as "has URL" even computers where I know the file doesn't exist. I'm not sure where I have gone wrong.
$a = Get-Content "C:\Computers.txt"
$windowsXP = "\\$i\c$\Documents and Settings\All Users\Desktop\file.url"
$windows7 = "\\$i\c$\Users\Public\Desktop\file.url"
ForEach ($i in $a){
#Test file on WindowsXP
if ((test-path $windowsXP) -eq $True)
{Write-Output "$i WindowsXP has URL"}
elseif ((test-path $windowsXP) -eq $False)
{Write-Output "$i WindowsXP needs URL"}
#Test file on Windows7
elseif((test-path $windows7) -eq $True)
{Write-Output "$I Windows7 has URL"}
elseif ((test-path $windows7) -eq $False)
{Write-Output "$I Windows7 needs URL"}
}