Instantly share code, notes, and snippets.

Embed
What would you like to do?
function Get-psBoundParameters {
[CmdletBinding()]
param
(
[bool]
$FooBar,
[Parameter(Mandatory = $false)]
[bool]
$WhatIs,
[Parameter(Mandatory = $false)]
[Switch]
$MyLittle
)
if ($PSBoundParameters.ContainsKey('WhatIs') -eq $false) {
$WhatIs = $false
}
if($PSBoundParameters.ContainsKey('MyLittle') -eq $false) {
$MyLittle = $true
}
Write-Host "Value of `$WhatIs = $WhatIs, NullOrEmpty $([string]::IsNullOrEmpty($WhatIs)), $($PSBoundParameters.ContainsKey('WhatIs'))"
Write-Host "Value of `$MyLittle = $MyLittle, NullOrEmpty $([string]::IsNullOrEmpty($MyLittle)), $($PSBoundParameters.ContainsKey('MyLittle'))"
}
Clear-Host
Get-psBoundParameters -FooBar $true -WhatIs $true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment