Your issue is the $file1 variable is not recognized as a string. The path should be enclosed in qoutes:
PS C:\Users\rsimmers> $test = C:\Test\123.txt
C:\Test\123.txt : The term 'C:\Test\123.txt' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that
the path is correct and try again.
At line:1 char:9
+ $test = C:\Test\123.txt
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Test\123.txt:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
PS C:\Users\rsimmers> $test = "C:\Test\123.txt"
You can shorten this to single line, but I made it two so it’s somewhat easier to read. This would produce an email body like “File Exists: True”:
we don’t know which date it will be so it’s not safe to use mmdd…i’m thinking to find the filename using extension ( because we will be having only one file with .zip extension )
also, in the above reply you mentioned “$file = “whatever{0}.zip” -f (Get-Date).ToString(“MMdd”)” but $file already contains path right ? how to proceed with this ?
Depending on the version of Powershell, you would have to test formatting. If there is a possibility of multiple files, I would use HTML email and use ConvertTo-HTML to generate a table from the $file object.
Our forums software is still HTML escaping some things in code blocks that are occasionally annoying. I think that particular sequence should just be a hyphen character.