$string = 'Hello'
if ($string -eq 'Hello') {
Write-Output "Hello World!"
}
if ($string -eq 'Hello') {
Write-Output "Hello World1!"
}
if ($string -eq 'Hello')
{
Write-Output "Hello World2!"
}
I use option 2
A lot of people will tell you that you SHOULD use option 3
THERE IS NO WRONG WAY OR RIGHT WAY
Write in the style that looks right for YOU. Style is a subjective thing that many people think should be dictated. There a best practices in coding - like use full cmdlet and parameter names - that should be followed but as far as I’m concerned as long as the code is readable and consistent it works.
Back in the Middle Ages European philosophers would argue about how many angels could dance on the head of a pin. Brace positioning is a similar argument
I have always used Option 2. Option 3 I could get used to but not really a fan of Option 1. None are incorrect, just whatever you are more comfortable with is good.