How do you programmatically get a list of all common parameters?
What about these static properties?
[System.Management.Automation.PSCmdlet]::CommonParameters[System.Management.Automation.PSCmdlet]::OptionalCommonParameters
The existing common parameters is the combination of both lists:
CommonParameters: Lists the common parameters that are added by the PowerShell engine to any cmdlet that derives from PSCmdlet.
OptionalCommonParameters: Lists the common parameters that are added by the PowerShell engine when a cmdlet defines additional capabilities (SupportsShouldProcess, SupportsTransactions)
i.e. All of them can exist, but the optional ones only exists if the cmdlet supports them. For detailed info see Cmdlet Class
Like this:
function Get-CommonParameterNames{ [CmdletBinding()] param() $MyInvocation.MyCommand.Parameters.Keys}