Powershell error with command call multline - Missing expression after unary operator '-'
I called the following command using backreferences to put parameters on separate lines
Create-WebSite -Name $targetWebSite `
-Location $targetWebSiteDir
However, this returns the following error:
- <<<< Location $targetWebSiteDir ` [<<==>>] Exception: Missing expression after unary operator '-'.
Any ideas what the problem is?
+3
source to share
1 answer
It turned out to be caused by the space after the backspace character (`).
So,
Create-WebSite -Name $targetWebSite ` <- SPACE HERE
-Location $targetWebSiteDir
became
Create-WebSite -Name $targetWebSite `<- NO SPACE
-Location $targetWebSiteDir
Once I removed all the space everything works correctly.
+4
source to share