Error: powershell else: The term ‘else’ is not recognized as the name of a cmdlet, function, script file, or operable program.
vscode gave me this error. When i researched this i found out it was caused because of the if else statement was on several lines. So After
If () {
#something
}
else
{
#The bracket is on a different line then the "else" statment. This will break the script.
}
If (){
#something
}else{
#this will NOT break
}
I have searched the web and tried several things. When i removed PSreadline module and installed the laters version (2.0.2) It was solved. I needed to remove the PSReadline directory in the module folder. The long story here on Stackoverflow.