-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
Get-Performance.ps1
34 lines (25 loc) · 944 Bytes
/
Get-Performance.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<#
.SYNOPSIS
Get performance metrics using the WinSAT utility.
#>
using assembly System.Xml.Linq
using namespace System.Xml.Linq
if (-not (Get-Command 'winsat' -ErrorAction:Ignore))
{
throw 'WinSAT is not installed on this system'
}
if (!(Test-Elevated (Split-Path -Leaf $PSCommandPath) -warn)) { return }
$storepath = Join-Path $env:windir 'Performance\WinSAT\DataStore'
if (!(Test-Path $storepath))
{
New-Item $storepath -ItemType Directory -Force
}
Write-Host "`nGathering Statistics..." -ForegroundColor Yellow
winsat formal
$file = (Get-Item "${storepath}\*formal*.xml" | Sort-Object -Descending -Property CreationTime | Select-Object -First 1).FullName
Write-Host "`nReformating result file" -ForegroundColor Yellow
[XElement]::Load($file).Save($file, [SaveOptions]::None)
Write-Host "`nReporting from ${file}" -ForegroundColor Yellow
$xml = [xml](Get-Content -Path $file)
# show just WinSPR node from XML
$xml.WinSAT.WinSPR