|
| 1 | +# Copyright (c) Microsoft Corporation. |
| 2 | +# Licensed under the MIT License. |
| 3 | + |
| 4 | +<# |
| 5 | + .Synopsis |
| 6 | + Launches WPA UI with the Microsoft-Performance-Tools-Linux plugins |
| 7 | +#> |
| 8 | + |
| 9 | +Param( |
| 10 | + [parameter(Mandatory=$false)] |
| 11 | + [alias("i")] |
| 12 | + $InputFile, |
| 13 | + [parameter(Mandatory=$false)] |
| 14 | + [alias("p")] |
| 15 | + $WpaProfile, |
| 16 | + [parameter(Mandatory=$false)] |
| 17 | + [alias("l")] |
| 18 | + $LinuxPerfToolsPluginFolder |
| 19 | + ) |
| 20 | + |
| 21 | +Write-Host "Please see https://aka.ms/linuxperftools for help" |
| 22 | + |
| 23 | +if (-not $LinuxPerfToolsPluginFolder -or -not (Test-Path -Path $LinuxPerfToolsPluginFolder -ErrorAction Ignore | Out-Null)) |
| 24 | +{ |
| 25 | + $scriptPath = Get-Item (Split-Path $MyInvocation.MyCommand.Path -Parent) |
| 26 | + $LinuxPerfToolsPluginFolder = $scriptPath.Parent.Parent.FullName |
| 27 | +} |
| 28 | +Write-Host "Using root folder as:" $LinuxPerfToolsPluginFolder |
| 29 | + |
| 30 | +if ($LinuxPerfToolsPluginFolder) |
| 31 | +{ |
| 32 | + $localLinuxPerfWpaAddins = Join-Path -Path $LinuxPerfToolsPluginFolder -ChildPath "MicrosoftPerfToolkitAddins\LTTngDataExtensions" # TODO - Remove LTTngDataExtensions path to include all plugins - Bug only 1 extension is supported at a time in current ADK DROP" |
| 33 | +} |
| 34 | + |
| 35 | +Write-Host "Using plugins folder as:" $localLinuxPerfWpaAddins |
| 36 | + |
| 37 | +if ($LinuxPerfToolsPluginFolder -and -not (Test-Path -Path $localLinuxPerfWpaAddins)) |
| 38 | +{ |
| 39 | + Write-Host "Please download the latest release from https://github.com/microsoft/Microsoft-Performance-Tools-Linux/releases" |
| 40 | + Start-Process "https://github.com/microsoft/Microsoft-Performance-Tools-Linux/releases" |
| 41 | + Pause |
| 42 | + Exit |
| 43 | +} |
| 44 | + |
| 45 | +$wpaProcess = "C:\Program Files (x86)\Windows Kits\10\Windows Performance Toolkit\wpa.exe" |
| 46 | + |
| 47 | +if (-not (Test-Path -Path $wpaProcess)) |
| 48 | +{ |
| 49 | + Write-Host "Please download the latest ADK Preview and install Windows Performance Toolkit" |
| 50 | + Start-Process "https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewADK" |
| 51 | + Pause |
| 52 | + Exit |
| 53 | +} |
| 54 | + |
| 55 | +$startInfo = New-Object System.Diagnostics.ProcessStartInfo |
| 56 | +$startInfo.FileName = $wpaProcess |
| 57 | + |
| 58 | +if ($InputFile) |
| 59 | +{ |
| 60 | + $paramFile = Get-Item $InputFile -ErrorAction Continue |
| 61 | + if ($paramFile.Exists) |
| 62 | + { |
| 63 | + if ($WpaProfile) |
| 64 | + { |
| 65 | + $startInfo.Arguments = "-i `"$InputFile`" -profile `"$WpaProfile`" -addsearchdir `"$localLinuxPerfWpaAddins`"" |
| 66 | + } |
| 67 | + else |
| 68 | + { |
| 69 | + $startInfo.Arguments = "-i `"$InputFile`" -addsearchdir `"$localLinuxPerfWpaAddins`"" |
| 70 | + } |
| 71 | + } |
| 72 | +} |
| 73 | +else |
| 74 | +{ |
| 75 | + # TODO - Add back in for just launch - Current ADK DROP has bug to not allow launch w/o -i |
| 76 | + #$startInfo.Arguments = "-addsearchdir `"$localLinuxPerfWpaAddins`"" |
| 77 | + Write-Error "Current ADK DROP has bug to not allow launch WPA UI just configured with plugins (use -i and -addsearchdir)" |
| 78 | + Pause |
| 79 | + Exit |
| 80 | +} |
| 81 | + |
| 82 | +Write-Host "Launching" $wpaProcess $startInfo.Arguments |
| 83 | + |
| 84 | +$startInfo.RedirectStandardOutput = $true |
| 85 | +$startInfo.UseShellExecute = $false |
| 86 | +$startInfo.CreateNoWindow = $false |
| 87 | + |
| 88 | +$process = New-Object System.Diagnostics.Process |
| 89 | +$process.StartInfo = $startInfo |
| 90 | +$process.Start() |
| 91 | + |
| 92 | +sleep 1 |
| 93 | +if ($process.HasExited) |
| 94 | +{ |
| 95 | + Write-Host "Process StdOut:" |
| 96 | + Write-Host $process.StandardOutput.ReadToEnd() |
| 97 | +} |
| 98 | + |
0 commit comments