Solved

powershell script to verify if a file exists

Posted on 2012-04-02
2
649 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 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 69

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Utilizing an array to gracefully append to a list of EmailAddresses
This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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