13

I've called the following command, using backticks to place the parameters on separate lines

Create-WebSite -Name $targetWebSite ` 
    -Location $targetWebSiteDir

However this is returning the following error:

- <<<< Location $targetWebSiteDir ` [<<==>>] Exception: Missing expression after unary operator '-'.

2 Answers 2

26

This turned out to be caused by a space being present after the backtick (`) character.

So,

Create-WebSite -Name $targetWebSite ` <- SPACE HERE
    -Location $targetWebSiteDir

became

Create-WebSite -Name $targetWebSite `<- NO SPACE
    -Location $targetWebSiteDir

Once I removed the space everything ran correctly.

Sign up to request clarification or add additional context in comments.

Comments

4

I have resolved this issue by using \ at end of line or we can remove spaces. For you it could

Create-WebSite -Name $targetWebSite `\ 
    -Location $targetWebSiteDir

1 Comment

While this code may solve the question, including an explanation of how and why this solves the problem would really help to improve the quality of your post, and probably result in more up-votes. Remember that you are answering the question for readers in the future, not just the person asking now. Please edit your answer to add explanations and give an indication of what limitations and assumptions apply.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.