Solved

powershell script to verify if a file exists

Posted on 2012-04-02
2
643 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 68

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

Hi all.   The other day I had to change the passwords for a bunch of users on the fly. Because they were so many, I decided to do it in an automated way and I would like to share it with you all.   If you are not doing it directly in a Domain Co…
Utilizing an array to gracefully append to a list of EmailAddresses
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now