troubleshooting Question

Check a file exist with Powershell.

Avatar of nav2567
nav2567Flag for United States of America asked on
Powershell
5 Comments1 Solution113 ViewsLast Modified:
Hello,

I am working on this PS script to copy some data from a share drive to a folder in the user's profile.  Prior to the copy, I need to make sure the "install-finished.txt" file is not in the desktop folder first.  

Please advise if the below will work.  Thanks very much!


if (-not (Test-Path $env:USERPROFILE\desktop\install-finished.txt)) {
copy-item -path "\\server1\share1" - destination ${env:UserProfile}\AppData\Local\software1 -recurse -force
}
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros