WindowsVersion.psm1

function Format-WindowsVersion
{

    [CmdletBinding()]

    param
    (
        [Parameter(Mandatory = $true, ValueFromPipeline = $true)]
        [String]
        $VersionString,

        [Switch]
        $ShowBuild
    )

    Process
    {
        Write-Verbose "Processing Version String $_"
        
        Write-Verbose "Converting to System.Version Object"
        $version = [Version] $_

        
        
        
        Write-Verbose "Derivating actural OS from object"

        $os = switch ($version.Major, $version.Minor -join ".") {
            '10.0' { "Windows 10/windows Server 2016" }
            '6.3'  {"windows 8.1/windows Server 2012R2"}
            '6.2' {"windwos 8/windows Server 2012"}
            '6.1' {"windows 7/windows Server 2008R2"}
            '6.0' {"windows Vista/windows Server2008"}
            '5.2' {"windows XP Professional/windows Server 2003R2"}
            default {"windows XP/windows Server 2003 or older"}
        }

        if ($ShowBuild){
            $os + " build " + $version.Build
        }else {
            $os
        }
          
    }
}

function Get-WindowsVersion
{
    Get-WmiObject -Class Win32_OperatingSystem | Select-Object -ExpandProperty Version
}