winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

Get-WinGetVersion.ps1 (664B)


      1 Function Get-WinGetVersion {
      2     <#
      3         .SYNOPSIS
      4         Gets the version from the Windows Package Manager.
      5         
      6         .DESCRIPTION
      7         By running this cmdlet, it will retrieve the version of the Windows Package Manager installed on the local system.
      8 
      9         .EXAMPLE
     10         Get-WinGetVersion
     11     #>
     12 
     13     BEGIN
     14     {
     15         [string[]] $WinGetArgs = "--version"
     16     }
     17     PROCESS
     18     {
     19         try {
     20             $Result = [version](& "winget" $WinGetArgs).trimstart("v")
     21         }
     22         catch {
     23             $Result = [version]"0.0.0.0"
     24         }
     25     }
     26     END
     27     {
     28         return $Result
     29     }
     30 }
     31 
     32 Export-ModuleMember -Function Get-WinGetVersion