Libraries/Lib.Linux.Debian.Debian/Lib.Linux.Linux.Debian.Debian.psm1

<#
    .SYNOPSIS
    Get the Product name of the OS
#>

function Get-OSLongCodeName {
    [CmdletBinding()][OutputType([String])]Param (
        [switch]$Online,
        [string]$Root = "/"
    )
    Begin {
        Write-EnterFunction
    }

    Process {
        if ($Online) { $Root = '/' }
        $value = ""
        $fileExist = Test-Path -Path "$Root/etc/os-release" -PathType Leaf
        if ($fileExist) {
            # $distrib = (Get-Content "$Root/etc/os-release" | where { $_ -match "^NAME=" }).split("=")[1].replace('"','')
            $value = Get-PropertyValueFromFile -Filename "$Root/etc/os-release" -Propertyname "VERSION_CODENAME"
            if ([string]::IsNullOrEmpty($value)) {
                $value = Get-PropertyValueFromFile -Filename "$Root/etc/os-release" -Propertyname "VERSION_CODENAME"
                $value = $value.Split("(")[-1].Replace(")", "")
            }
            if ([string]::IsNullOrEmpty($value)) {
                $pretty_name = Get-PropertyValueFromFile -Filename "$Root/etc/os-release" -Propertyname "PRETTY_NAME"
                if ($pretty_name -match "/sid$") {
                    $value = ($pretty_name -split ' ')[-1]
                }
            }
        }

        return $value
   }

    End {
        Write-LeaveFunction
    }
}