public/Get-SkylineExperience.ps1

Function Get-SkylineExperience {
    <#
    .SYNOPSIS
    Gets the experience for a site collection or web
     
    .DESCRIPTION
    Gets the experience for a site collection or web
 
    .EXAMPLE
    Get-SkylineExperience -Scope Site
 
    .EXAMPLE
    Get-SkylineExperience -Scope Web
 
    .PARAMETER Scope
    Specify whether to get the experience on the Web or Site
 
    .PARAMETER Web
    The web to apply the command to. Omit this parameter to use the current web.
     
    #>


    [cmdletbinding()]
    param(
        [parameter(Mandatory = $True)]
        [ValidateSet("Web","Site")]
        [string]$Scope,
        [Microsoft.SharePoint.Client.Web]$Web
    )

    Process
    {
        Write-Debug ( "Running $($MyInvocation.MyCommand).`n" + "PSBoundParameters:`n$($PSBoundParameters | Format-List | Out-String)")

        Try
        {     
            $PSBoundParameters.Remove("Scope") | Out-Null  

            $WebFeatureId = "52E14B6F-B1BB-4969-B89B-C4FAA56745EF"
            $SiteFeatureId = "E3540C7D-6BEA-403C-A224-1A12EAFEE4C4"
            
            $Result = ""

            $WebFeature = Get-PnPFeature -Scope Web @PSBoundParameters | Where-Object {$_.DefinitionId -eq $WebFeatureId}                
            $SiteFeature = Get-PnPFeature -Scope Site @PSBoundParameters | Where-Object {$_.DefinitionId -eq $SiteFeatureId}                
            
            if ($Scope -eq "Web") 
            {
                $Result = if ($WebFeature -ne $null -or $SiteFeature -ne $null) {"Classic"} else {"Modern"}
            }
            elseif ($Scope -eq "Site")
            {
                $Result = if ($SiteFeature -ne $null) {"Classic"} else { "Modern"}
            }
        
            return $Result
        }
        Catch
        {
            Throw $_
        }
    }
}