none
Script to check if multiple files exist powershell - not working RRS feed

  • Question

  • $ServerName = Get-Content "c:\dev\Computers.txt" 

    $path = 'C$\Program Files (x86)\Microsoft Office\root\Office16\winword.exe'
    $path = 'C$\Program Files (x86)\Microsoft Office\root\Office16\EXCEL.EXE'
    $path = 'C$\Program Files (x86)\Microsoft Office\root\Office16\POWERPNT.EXE'
    $path = 'C$\Program Files (x86)\Microsoft Office\root\Office16\OUTLOOK.EXE' 
      
    foreach ($Server in $ServerName) {  
      
            if (test-Connection -ComputerName $Server -Count 2 -Quiet ) {   
              
                $computers | % { 
                '{0}: {1}' -f $_, (Test-Path -LiteralPath "\\$_\$path") }
              
                        } else  
                          
                        {"$Server not pinging"  
                  
                        }      
              
                                    } 
    • Moved by Bill_Stewart Wednesday, September 4, 2019 9:32 PM Unanswerable drive-by question
    Friday, April 26, 2019 6:29 PM

All replies