I've created a function in Powershell and want to pass the Parameter -Foo as a Boolean.
I've simplified my Use-Case for Visualization:
function Get-Foobar {
[CmdletBinding()]
param (
[bool]$Foo
)
if ($Foo) {
Write-Host "Foo!"
}
else {
Write-Host "Bar!"
}
}
The function works as expected, when I call the function Get-Foobar -Foo $true. But this is not what I want. Just Get-Foobar -Foo should suffice.
Referring to the documentation, specifying the parameter when calling the function should already return a true. But apparently this does not work.