InstallProcDump.ps1 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <#
  2. .SYNOPSIS
  3. Installs ProcDump into a folder in this repo.
  4. .DESCRIPTION
  5. This script downloads and extracts the ProcDump.
  6. .PARAMETER Force
  7. Overwrite the existing installation
  8. #>
  9. param(
  10. [switch]$Force
  11. )
  12. $ErrorActionPreference = 'Stop'
  13. $ProgressPreference = 'SilentlyContinue' # Workaround PowerShell/PowerShell#2138
  14. Set-StrictMode -Version 1
  15. $repoRoot = Resolve-Path "$PSScriptRoot\..\.."
  16. $installDir = "$repoRoot\.tools\ProcDump\"
  17. $tempDir = "$repoRoot\obj"
  18. if (Test-Path $installDir) {
  19. if ($Force) {
  20. Remove-Item -Force -Recurse $installDir
  21. }
  22. else {
  23. Write-Host "ProcDump already installed to $installDir. Exiting without action. Call this script again with -Force to overwrite."
  24. exit 0
  25. }
  26. }
  27. Remove-Item -Force -Recurse $tempDir -ErrorAction Ignore | out-null
  28. mkdir $tempDir -ea Ignore | out-null
  29. mkdir $installDir -ea Ignore | out-null
  30. Write-Host "Starting ProcDump download"
  31. & $PSScriptRoot\Download.ps1 "https://download.sysinternals.com/files/Procdump.zip" "$tempDir/ProcDump.zip"
  32. Write-Host "Done downloading ProcDump"
  33. Expand-Archive "$tempDir/ProcDump.zip" -d "$tempDir/ProcDump/"
  34. Write-Host "Expanded ProcDump to $tempDir"
  35. Write-Host "Installing ProcDump to $installDir"
  36. Move-Item "$tempDir/ProcDump/*" $installDir
  37. Write-Host "Done installing ProcDump to $installDir"
  38. if ($env:TF_BUILD) {
  39. Write-Host "##vso[task.setvariable variable=ProcDumpPath]$installDir"
  40. Write-Host "##vso[task.prependpath]$installDir"
  41. }