Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iskernel/5988817 to your computer and use it in GitHub Desktop.
Save iskernel/5988817 to your computer and use it in GitHub Desktop.
How to fix a corrupt directory using ChkDsk.
<#
When you attempt to open, delete or rename a file or folder using Windows NT
Explorer, File Manager or a command prompt, you may receive one of the
following error messages:
<drive>:\<folder> is not accessible
The file or directory is corrupt and non-readable.
The file or directory is corrupt and non-readable.
The file or directory \<folder> is corrupt and unreadable.
#>
#The drive you want to check
$drive = "d:"
#Runs chkdsk as administrator (requires admin password)
runas.exe /savecred /user:administrator "chkdsk /f $drive"
#Pauses
Write-Host "Press any key to continue ..."
$x = $host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment