Quantcast
Channel: PowerShell General
Viewing all articles
Browse latest Browse all 10624

Basic Else not working

$
0
0

This is a very basic script but I cannot get the Else to launch notepad. I have tried:

& “C:\windows\notepad.exe"
Invoke-Item “C:\Windows\notepad.exe"

But it refuses to work when the condition is met. What am I doing wrong ? Here is the original script:

Set-ExecutionPolicy Unrestricted
Import-Module Pscx
$ChkFile = "d:\files\*.in"
$FileExists = Test-Path $ChkFile
If ($FileExists -eq $True) {
copy d:\files\*.in d:\files\forconversion
del d:\files\*.in
convertto-unixlineending d:\files\forconversion\*.in d:\files
del d:\files\forconversion\*.in
}
Else ($FileExists -ne) {
CD "c:\windows\"
notepad.exe
}

Viewing all articles
Browse latest Browse all 10624