Invalid assignment expression. The left hand side of an assignment operator needs to be something that can be assigned to like a variable or a property
The cause of the error was that I had added a line of code in front of my param declaration:
Set-StrictMode -Version 2 param( [string][parameter(mandatory=$true )] $WebsitePhysicalPath,
this can occur if you have a variable declared before the "param()" declarations.
ReplyDeleteThis one of those things that makes me want to TP the house of the developer in charge of issuing those non-sensical error messages. I just lost time that I could have spent on better things because of such lack of clarity. Thanks for posting this.
ReplyDeleteThanks for the post. This was exactly my problem; I was trying to add Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010 above my "Param()"
ReplyDelete#Powershell BUG: Cannot use Param if you have function inside your script
ReplyDeleteFunction a ([string]$var){
}
param([string]$foo = "foo")
Write-Host "Arg: $foo"
Write-Host "Arg: $bar"
Comment out the function declaration and it works!
---------------------------------
found answer to my own problem.
#workAround: Place the param( Statement for the Main at the TOP of the script, before the Function declaration.
Hi is this still an active conversation?
ReplyDelete