When you declare a parameter as type [switch], PowerShell will set the corresponding variable to $True or $False inside the function. You either include the parameter when running the function, or you don’t – just like with -Force on Remove-ChildItem, or -Recurse on Get-ChildItem.
You can also pass an explicit value to a switch:
Do-Something -Switch:$true
If that’s an easier way of passing the value you want. Finally, it’s possible to use splatting, which lets you assemble a hash table of parameters and values. That way, you can programmatically add, or not add, a switch parameter to the hash table before calling the function.