Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

powershell script to verify if a file exists

Posted on 2012-04-02
2
Medium Priority
?
658 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
2 Comments
 
LVL 27

Accepted Solution

by:
KenMcF earned 2000 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 71

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
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 anti-spam), the admin…
Loops Section Overview

885 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