2021-09-11 11:37:22 +02:00
|
|
|
|
<#
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.SYNOPSIS
|
|
|
|
|
check-file-system.ps1 [<drive>]
|
|
|
|
|
.DESCRIPTION
|
2021-09-08 15:17:27 +02:00
|
|
|
|
Checks the file system of a drive (needs admin rights)
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> .\check-file-system.ps1 C
|
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
2021-08-29 17:50:03 +02:00
|
|
|
|
Author: Markus Fleschutz · License: CC0
|
2021-04-05 10:48:34 +02:00
|
|
|
|
#>
|
|
|
|
|
|
2021-09-11 11:37:22 +02:00
|
|
|
|
#Requires -RunAsAdministrator
|
|
|
|
|
|
2021-07-15 15:51:22 +02:00
|
|
|
|
param([string]$Drive = "")
|
2021-04-05 10:48:34 +02:00
|
|
|
|
|
|
|
|
|
try {
|
2021-08-24 20:46:03 +02:00
|
|
|
|
if ($Drive -eq "" ) { $Drive = read-host "Enter drive (letter) to check" }
|
|
|
|
|
|
2021-04-05 11:03:12 +02:00
|
|
|
|
$Result = repair-volume -driveLetter $Drive -scan
|
|
|
|
|
if ($Result -ne "NoErrorsFound") { throw "'repair-volume' failed" }
|
2021-04-05 10:48:34 +02:00
|
|
|
|
|
2021-08-24 20:46:03 +02:00
|
|
|
|
"✔️ file system on drive $Drive is clean"
|
2021-04-05 10:48:34 +02:00
|
|
|
|
exit 0
|
|
|
|
|
} catch {
|
2021-05-02 21:30:48 +02:00
|
|
|
|
write-error "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
2021-04-05 10:48:34 +02:00
|
|
|
|
exit 1
|
|
|
|
|
}
|