I'm not sure why you're using a separate function to determine the name of the .html file, but in any case, if you want to open one file based on whether another file exists, it's as simple as
if (Get-Item -ea SilentlyContinue <path of file to check for>) {
Invoke-Item <path of file to open>
}
(Assuming that by "open" you mean the default action associated with the file extension - which is what you're essentially doing when you use & "<path>"
.)
So, to put it in terms of your code more specifically:
if (Get-Item -ea SilentlyContinue "\\*****path to file\$Textbox1.html") {
Invoke-Item '\\*****path to file\HTA3.hta'
}
You didn't specify what $Textbox1 is and how it's defined, but I'm inferring that it contains the base name of the .html file.
I single-quoted the path argument to Invoke-Item because you show a static path to the .hta file; if you're using any variables to determine the path, be sure to change to double quotes.
The -ne operator means "not equal", so in fact you're trying to open the .hta file only if the .html file doesn't exist. The code you have, although overly cumbersome, does work other than that, so that's probably the reason it isn't working for you.
Another tip is that you don't need to test a boolean condition for equality or inequality.
if (<boolean> -eq $true) { ...
is the same asif (<boolean>) { ...
, and likewiseif (<boolean> -ne $true) { ...
is the same asif (! <boolean>) { ...
. So, your if statement using using the .NET class (which you don't really need) should be simplyif ([IO.File]::Exists($filePath) { ...
.