Skip to content

Instantly share code, notes, and snippets.

@RichieBzzzt
Created January 25, 2018 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RichieBzzzt/d3ae7f03a208ba3029ddba895c2f0321 to your computer and use it in GitHub Desktop.
Save RichieBzzzt/d3ae7f03a208ba3029ddba895c2f0321 to your computer and use it in GitHub Desktop.
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