PoshCode Archive  Artifact [c77fd03a0f]

Artifact c77fd03a0fd458db830f2c067f16aec014afc1b7cdaceadefe3401b313e18c4d:

  • File Get-Parameter.ps1 — part of check-in [c365f25d27] at 2018-06-10 13:02:06 on branch trunk — Not quite finished effort at a script intended to spit out the parameters of a cmdlet. I’m sure there’s a better but this is…adequate for now. (user: unknown size: 1097)

# encoding: ascii
# api: powershell
# title: Get-Parameter
# description: Not quite finished effort at a script intended to spit out the parameters of a cmdlet.  I’m sure there’s a better but this is…adequate for now.
# version: 0.1
# license: CC0
# x-poshcode-id: 186
# x-derived-from-id: 255
# x-archived: 2009-11-13T21:31:03
#
#
param($Cmdlet) $CmdletInfo = Get-Command -CommandType Cmdlet -Name $Cmdlet
    if ( $? ) {
        if ($CmdletInfo.GetType().Name -eq "CmdletInfo" ) {
            $parsed = $CmdletInfo.Definition `
                -replace "\] \[", "]`n[" `
                -replace "> \[", ">`n[" `
                -replace "$Cmdlet " `
                -split "`n" `
                -replace "\[-" `
                -replace "\]$"
            $parsed = $parsed | Sort-Object -Unique
            switch -regex ($parsed) {
                "^\["    { Write-host -ForegroundColor Green $_ }
                "Confirm|Debug|Verbose|WhatIf" { Write-Host -ForegroundColor Blue $_ }
                Default { Write-Host $_ }
            }
        }
    }