Solved

powershell script to verify if a file exists

Posted on 2012-04-02
2
654 Views
Last Modified: 2012-06-27
Hi All,

I need a PS to read in a text that contains workstation name, then look for c:\folder and see if a perticular file is in there, give me yes/no result in a csv file with machine name,

Please advise.

Thanks
0
Comment
Question by:fireburn11
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
KenMcF earned 500 total points
ID: 37798010
You can do something like this

$Comps = get-content c:\servers.txt
$Comps | foreach {
If (Test-Path \\$_\c$\folder\file){
    "$_, YES"
    }
    Else{
        "$_,NO"
    }
}
0
 
LVL 70

Expert Comment

by:Qlemo
ID: 37848957
That is a very simplistic approach, and requires that
the remote PC is reachable, else network timeouts will happen, slowing down the script significantly, and showing error messages on the console.
we have admin privileges, and the default shares are not disabled by GPO or registry settings.
Nevertheless, it could work for you that way.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A procedure for exporting installed hotfix details of remote computers using powershell
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…

635 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question