Solved

powershell script to verify if a file exists

Posted on 2012-04-02
2
640 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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

12 Experts available now in Live!

Get 1:1 Help Now