Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Test-Path

$
0
0

Hello

I was wondering if someone could answer a question and maybe tell me what I am doing incorrectly

When I do
Test-Path '\\Server\Folder1\Folder2\Folder3\7wrb@01!.docx'    This returns true

When I try and read it from a file it returns false
Something like this

Get-Content C:\Data\File1.txt| Select-Object `
{
    $r=if(Test-Path -Path $_){"$_ exists."}
    else{"$_ does NOT exist!"}
    $r
}

What I want to do is if the file exists I want to copy it to another folder and if it does not exist I want to generate a file stating it was not copied / Found.

Not sure what I am doing incorrectly I am just starting to use Powershell

 

Thank you for your assistance


Viewing all articles
Browse latest Browse all 6937

Trending Articles