Windows Experience Index on 8.1

Firstly, thanks to https://www.intowindows.com/get-windows-experience-index-wei-score-in-windows-8-1/ for the underlying magic: WinSAT.exe.

Under Windows 8.1, the Windows Experience Index is no longer exposed under Computer | System Properties.  That’s fine.  It’s primarily used for bragging rights, so it’s not a huge functionality drop.  However, for those who want to continue the bragging, here’s how to generate and extract the scores with PSH:

 function Get-WindowsExperienceIndex
{
    <#
    .synopsis
    Generates Windows Experience Index score

    .description
    When run as administrator, calls WinSAT.exe to generate Windows Experience Index scores, displays as an XML element.

    .inputs
    None

    .outputs
    [XmlElement]

    .references
    https://www.intowindows.com/get-windows-experience-index-wei-score-in-windows-8-1/

    #>

    param (
        [switch]$Verbose
    )

    if ($Verbose)
    {
        $script:VerbosePreference = 'continue';
    }

    $dataStoreDir = "$env:WinDir\Performance\WinSAT\DataStore";

    if (!(Get-Command -ErrorAction SilentlyContinue WinSAT))
    {
        $msg = "$($MyInvocation.MyCommand.Name) cannot find WinSAT.exe";
        Write-Error -ErrorAction SilentlyContinue -Message $msg;
        throw $msg;

    } # if (!(Get-Command -ErrorAction SilentlyContinue WinSAT))

    if (!(
            New-Object Security.Principal.WindowsPrincipal (
                [Security.Principal.WindowsIdentity]::GetCurrent()
            )
        ).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator))
    {
        $msg = "$($MyInvocation.MyCommand.Name) must be run as Administrator";
        Write-Error -ErrorAction SilentlyContinue -Message $msg;
        throw $msg;

    } # if (!(New-Object Security.Principal.WindowsPrincipal (...


    5..1 | 
    % {
        Write-Progress -Id 100 "NOTE: WinSAT.exe takes a bit of time" "Starting in $_ seconds";
        Start-Sleep -Seconds 1;

    } # 5..1 | 

    WinSAT formal -restart | 
    % {
        $line = $_ -replace '^>?\s*';
        if ($line -match '^Running')
        {
            $writeProgressId = 200;

        } # if ($line -match '^Running')
        elseif ($line -match '^Run Time')
        {
            $writeProgressId = 300;

        } # if ($line -match '^Running') ... elseif
        else
        {
            $writeProgressId = 100;

        } # if ($line -match '^Running') ... else

        Write-Progress -Id $writeProgressId (Get-Date) $line;

        if ($line -match '/s')
        {
            Write-Verbose $line;
        } # if ($line -match '/s')

    } # WinSAT formal -restart |

    $dataStoreFile = Get-ChildItem "$dataStoreDir\*Formal.Assessment*.WinSAT.xml" |
    Sort-Object -Descending -Property LastWriteTime |
    Select-Object -First 1

    if (!$dataStoreFile)
    {
        $msg = "$($MyInvocation.MyCommand.Name) cannot find $dataStoreDir\Formal.Assessment*.WinSAT.xml";
        Write-Error -ErrorAction SilentlyContinue -Message $msg;
        throw $msg;
    
    } # if (!$dataStoreFile)

    if ($xml = (Get-Content $dataStoreFile.FullName) -as [xml])
    {
        $xml.SelectSingleNode("//WinSPR");

    } # if ($xml = (Get-Content $dataStoreFile.FullName) -as [xml])
    else
    {
        $msg = "$($MyInvocation.MyCommand.Name) $($dataStoreFile.FullName) cannot be parsed as XML";
        Write-Error -ErrorAction SilentlyContinue -Message $msg;
        throw $msg;

    } # if ($xml = (Get-Content $dataStoreFile.FullName) -as [xml]) ... else
    
}

Oh, and the scores now go up to 8.1.