powershell PowerShell:Get-ComparableVersion

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了powershell PowerShell:Get-ComparableVersion相关的知识,希望对你有一定的参考价值。

function Get-ComparableVersion {
    [CmdletBinding(SupportsShouldProcess=$true,DefaultParameterSetName="None")]
    PARAM(
        [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ParameterSetName="p1")]
        [String]
        $Version
    )

    BEGIN {
        Write-Verbose $Version
    }

    PROCESS {
        $Version_Sections = $null
        $Version_Sections = $Version -split ("\.")
        # Validate all sections are integers
        foreach ($Version_Section In $Version_Sections) {
            if (![int32]::TryParse($Version_Section, [ref]"")) {return}
        }

        $LongVersion = $Version_Sections[0]
        foreach ($SectionIndex in (1..($Version_Sections.Length - 1))) {
            Write-Verbose ([int]$Version_Sections[$SectionIndex]).ToString("0" * 11)
            $LongVersion += ([int]$Version_Sections[$SectionIndex]).ToString("0" * 11)
        }
        $LongVersion
    }

    END {
    }
}

Clear-Host
Get-ComparableVersion -Version '15.0.4823.1000'

以上是关于powershell PowerShell:Get-ComparableVersion的主要内容,如果未能解决你的问题,请参考以下文章

powershell PowerShell:Get-Handles

powershell PowerShell:Get-MicrosoftUpdates

powershell PowerShell:Get-NetPrefixPolicy

powershell PowerShell:Get-FileHash

powershell PowerShell:Get-ComparableVersion

powershell PowerShell:Get-OSBitness