2021-04-21 19:53:52 +02:00
|
|
|
|
<#
|
2021-07-13 21:10:02 +02:00
|
|
|
|
.SYNOPSIS
|
|
|
|
|
check-file-system.ps1 [<drive>]
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
Checks the validity of the file system (needs admin rights)
|
|
|
|
|
.EXAMPLE
|
|
|
|
|
PS> .\check-file-system.ps1 C
|
|
|
|
|
.LINK
|
|
|
|
|
https://github.com/fleschutz/PowerShell
|
|
|
|
|
.NOTES
|
2021-08-03 15:53:57 +02:00
|
|
|
|
Author: Markus Fleschutz
|
|
|
|
|
License: CC0
|
2021-04-05 10:48:34 +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
|
|
|
|
|
}
|