Libraries/Lib.Windows.Winnt.Windows.Windows11/Lib.Windows.Winnt.Windows.Windows11.psm1

<#
Windows 11 specific library
 
- use DisplayVersion instead of ReleaseId
- replace "Windows 10" with "Windows 11" in productName
#>


<#
.SYNOPSIS
Fetch DisplayVersion attribute
 
.DESCRIPTION
DisplayVersion is a new attribute introduced in Windows 11 replacing ReleaseId
 
.PARAMETER Online
Parameter description
 
.PARAMETER Root
Parameter description
 
.EXAMPLE
An example
 
.NOTES
General notes
#>

function Get-OSDisplayVersion {
    [CmdletBinding()][OutputType([String])]Param (
        [switch]$Online,
        [string]$Root
    )
    Begin {
        Write-PwShFwOSEnterFunction
    }

    Process {
        if ($Online) {
            $RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
        } else {
            $RegPath = Mount-OfflineWindowsRegistry -Path "$Root\Windows" -Hive SOFTWARE
            $RegPath = $RegPath + "\Microsoft\Windows NT\CurrentVersion"
        }


        if ($PSVersionTable.PSVersion.Major -lt 5) {
            return (Get-ItemProperty $RegPath 'DisplayVersion' -ErrorAction:SilentlyContinue).DisplayVersion
        } else {
            return Get-ItemPropertyValue $RegPath -Name DisplayVersion
        }
   }

    End {
        Write-PwShFwOSLeaveFunction
    }
}

<#
.SYNOPSIS
Get the release ID of an OS
 
.DESCRIPTION
The release ID of an OS is often a number identifying OS in time.
It can return 1607 or 1809 on windows 10 or 16.04 or 18.10 on ubuntu.
 
.EXAMPLE
Get-OSReleaseId -Online
 
.NOTES
General notes
#>

function Get-OSReleaseId {
    [CmdletBinding()][OutputType([String])]Param (
        [switch]$Online,
        [string]$Root
    )
    Begin {
        Write-PwShFwOSEnterFunction
    }

    Process {
        return Get-OSDisplayVersion @PSBoundParameters
    }

    End {
        Write-PwShFwOSLeaveFunction
    }
}

function Get-OSProductname {
    [CmdletBinding()][OutputType([String])]Param (
        [switch]$Online,
        [string]$Root
    )
    Begin {
        Write-PwShFwOSEnterFunction
    }

    Process {
        if ($Online) {
            $RegPath = "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion"
        } else {
            $RegPath = Mount-OfflineWindowsRegistry -Path "$Root\Windows" -Hive SOFTWARE
            $RegPath = $RegPath + "\Microsoft\Windows NT\CurrentVersion"
        }


        if ($PSVersionTable.PSVersion.Major -lt 5) {
            $productName = (Get-ItemProperty $RegPath 'ProductName' -ErrorAction:SilentlyContinue).ProductName
        } else {
            $productName = Get-ItemPropertyValue $RegPath -Name ProductName
        }

        return ($productName -replace "Windows 10", "Windows 11")
   }

    End {
        Write-PwShFwOSLeaveFunction
    }
}

<#
    .SYNOPSIS
    Get the distribution of the OS
 
.PARAMETER Online
True to specify to fetch information from the running OS
 
.PARAMETER Root
The path to the root of an OS.
 
.EXAMPLE
Get-OSVersion -Online
 
.EXAMPLE
Get-OSVersion -Root F:\
 
#>

function Get-OSVersion {
    [CmdletBinding()][OutputType([String])]Param (
        [Parameter(ParameterSetName = 'ONLINE')][switch]$Online,
        [Parameter(ParameterSetName = 'ROOT')][string]$Root
    )
    Begin {
        Write-PwShFwOSEnterFunction
    }

    Process {
        return "11"
   }

    End {
        Write-PwShFwOSLeaveFunction
    }
}