The test code (test.ps1):
Param(
[string]$content = $null,
[switch]$flag = $false
)
Write-Host $content
Output:
PS C:\Users\powershell> .\test.ps1 PS C:\Users\powershell> .\test.ps1 -flag $true True PS C:\Users\powershell> .\test.ps1 -flag $false False PS C:\Users\powershell> .\test.ps1 -flag $true -content "lalala" lalala
No matter I set $content to $null, or "", or without any default value, the output is the same.
So why does $content take the value from $flag?