param (
[string]$ComputerName="Server01",
[string[]]$SEARCHTERMS=@("Unifi","Edge"),
[string]$IPAddress='10.11.12.243', #Dangling comma that i never see.
)
There must be a ... AND 1=1; trick like what is commonly done in sql statements to move parameters around without much thought.
CodePudding user response:
No, I think there is no trick that avoids this syntax error.
The only consolation is that if you use
The PROBLEMS
tab in the panel view (toggle with Ctrl-J) states the specific problem:
Missing expression after ','.
Making PowerShell tolerant of an extraneous (dangling) ,
after the last parameter declaration inside param(...)
- so as to make reordering parameter declarations less painful - has been officially suggested in the past - by a former core member of the PowerShell team, no less - but the suggestion was declined:
- See (declined) GitHub issue #8873, which also mentions not requiring
,
separators at all as a potential enhancement, analogous to how you can place elements inside@(...)
on separate lines to form array elements, without the need for a(nother) separator.
CodePudding user response:
param (
[string]$ComputerName="Server01",
[string[]]$SEARCHTERMS=@("Unifi","Edge"),
[string]$IPAddress='10.11.12.243', #Dangling comma that i never see.
[string]$DumbCommas='Extra Param to Protect me from commas.'
)
Needs a shorter variable name, but it will do.