Last active
August 14, 2025 20:13
-
-
Save jwmoss/b9a3bd1c5ff8c2bd4add97c598909f94 to your computer and use it in GitHub Desktop.
speed d drive
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Test C: drive speed with DiskSpd (fixed arg passing) | |
| # --- Settings --- | |
| $diskspdUrl = "https://github.com/microsoft/diskspd/releases/download/v2.2/DiskSpd.ZIP" | |
| $diskspdExe = "$env:TEMP\diskspd.exe" | |
| $tempFile = "D:\diskspd_testfile.dat" # test file now on D: | |
| $outFile = "$env:TEMP\diskspd_results.txt" | |
| $fileSize = "1G" # test file size | |
| $duration = 30 # seconds | |
| $threads = 4 | |
| # --- Download DISKSPD if not found --- | |
| if (-not (Test-Path $diskspdExe)) { | |
| Write-Host "Downloading DISKSPD..." | |
| $zip = Join-Path $env:TEMP "diskspd.zip" | |
| Invoke-WebRequest -Uri $diskspdUrl -OutFile $zip | |
| Expand-Archive -Path $zip -DestinationPath $env:TEMP -Force | |
| Remove-Item $zip -Force | |
| # Find the right exe (prefer amd64/x64) | |
| $exeFound = Get-ChildItem -Path $env:TEMP -Filter "diskspd.exe" -Recurse | | |
| Sort-Object { if ($_.FullName -match 'amd64|x64') {0} else {1} } | | |
| Select-Object -First 1 | |
| if ($exeFound) { | |
| Copy-Item $exeFound.FullName $diskspdExe -Force | |
| } else { | |
| Write-Error "DISKSPD executable not found after extraction." | |
| exit 1 | |
| } | |
| } | |
| # --- Run Test --- | |
| Write-Host "Running DISKSPD test on C: drive..." | |
| # Build argument list explicitly so variables interpolate correctly | |
| $args = @( | |
| "-c$($fileSize)" | |
| "-d$($duration)" | |
| "-Sh" | |
| "-L" | |
| "-b64K" | |
| "-t$($threads)" | |
| "-o4" | |
| "-w50" | |
| $tempFile | |
| ) | |
| try { | |
| & $diskspdExe @args | Tee-Object -FilePath $outFile | |
| $code = $LASTEXITCODE | |
| } | |
| finally { | |
| if (Test-Path $tempFile) { Remove-Item $tempFile -Force } | |
| } | |
| Write-Host "`n=== DISKSPD Results ===" | |
| if (Test-Path $outFile) { | |
| Get-Content $outFile | |
| } else { | |
| Write-Warning "No results file was produced (DiskSpd likely failed before writing output)." | |
| } | |
| if ($code) { exit $code } else { exit 0 } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment