winget-cli icon indicating copy to clipboard operation
winget-cli copied to clipboard

Return a version object in Get-WinGetVersion

Open denelon opened this issue 1 year ago • 1 comments

Description of the new feature / enhancement

Get-WinGetVersion returns a string for the version with the "v" as the first character. It should probably be returning a version object.

Proposed technical implementation details

No response

denelon avatar Jul 26 '24 23:07 denelon

I would have it return a rich object.

Function Get-PSWinGetVersion {
    [CmdletBinding()]
    param (  )

    $Module = Get-Module -Name Microsoft.Winget.Client
    [Version]$WingetVersion = (winget -v).Substring(1)
    $OS = Get-CimInstance -ClassName Win32_OperatingSystem -Property Caption
    [PSCustomObject]@{
        PSTypeName      = 'PSWinGetVersion'
        ModuleVersion   = $Module.Version
        WingetVersion   = $WinGetVersion
        WinGetPath      = (Get-Command winget).Source
        PSVersion       = $PSVersionTable.PSVersion
        OperatingSystem = $os.Caption
        ComputerName    = $env:COMPUTERNAME
    }
}

This gives me good information for troubleshooting or documentation. image

jdhitsolutions avatar Aug 09 '24 16:08 jdhitsolutions