Private/Set-PDTypeName.ps1
|
function Set-PDTypeName { <# .SYNOPSIS Tags an object (in place) with a PSTypeName so the ToString overrides registered by Register-PDTypeFormat apply to it (internal helper). #> [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory, ValueFromPipeline)] [AllowNull()] [object]$InputObject, [Parameter(Mandatory, Position = 0)] [string]$TypeName ) process { if ($null -ne $InputObject -and $PSCmdlet.ShouldProcess($TypeName, 'Set PSTypeName')) { $InputObject.PSObject.TypeNames.Insert(0, $TypeName) } $InputObject } } |