Skip to content

Instantly share code, notes, and snippets.

@beatcracker
Created February 8, 2016 14:06
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 beatcracker/f8163ac1b8cdd449084c to your computer and use it in GitHub Desktop.
Save beatcracker/f8163ac1b8cdd449084c to your computer and use it in GitHub Desktop.
Compare function's internal properties (Adv. function vs Adv. function w/ CmdletBinding attribute)
Add-Type -Path .\KellermanSoftware.Compare-NET-Objects.dll
$CompareLogic = New-Object -TypeName KellermanSoftware.CompareNetObjects.CompareLogic
$Config = @{
MaxStructDepth = 999
MaxDifferences = 999
MaxByteArrayDifferences = 999
}
$CompareLogic.Config = $Config
function Use-CmdletBindingWithAdvParam {[CmdletBinding()] Param([Parameter()]$Foo) @{MyInvocation = $MyInvocation ; PSCmdlet = $PSCmdlet}}
function Use-AdvParam {Param([Parameter()]$Foo) @{MyInvocation = $MyInvocation ; PSCmdlet = $PSCmdlet}}
$CmdletBindingWithAdvParam = Use-CmdletBindingWithAdvParam
$AdvParam = Use-AdvParam
$MyInvocationDiff = $CompareLogic.Compare($CmdletBindingWithAdvParam.MyInvocation, $AdvParam.MyInvocation).Differences | Where-Object {$_.PropertyName -notlike '.MyCommand.ScriptBlock.Ast*'}
$PSCmdletDiff = $CompareLogic.Compare($CmdletBindingWithAdvParam.PSCmdlet, $AdvParam.PSCmdlet).Differences
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment