locked
powershell script to run chkdsk c: RRS feed

  • Question

  • I need a simple script to run the following command using apowershell ps1 file so that I don't have to manually start powershell and enter the following command;

    chkdsk c:

    I just want to check the health of drive C - I don't want to repair it.


    Asus P5Q3 Deluxe WiFi, Intel E8500 processor, 8gb DDR3 Gskill, Evga Nvidia Geforce 9800GT 512mb, onboard Marvel lan, onboard Ralink Wifi, Onboard Soundmax, 2 240gb Sata 2 SSD, 1 sata DVD drive. Win 8.1 Pro, Win Bus 64, Win 7 64, Mac os x 10.5.7 Please return to forum and post your results.

    Saturday, October 12, 2019 11:56 AM

Answers

  • Why Powershell? Just save this line to a file with a name of your choice and the extension .cmd and you're done. You might ad a second line with pause to be able to read the output before the console window gets closed.

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    • Marked as answer by snifferpro Saturday, October 12, 2019 5:14 PM
    Saturday, October 12, 2019 12:35 PM

All replies

  • Why Powershell? Just save this line to a file with a name of your choice and the extension .cmd and you're done. You might ad a second line with pause to be able to read the output before the console window gets closed.

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    • Marked as answer by snifferpro Saturday, October 12, 2019 5:14 PM
    Saturday, October 12, 2019 12:35 PM
  • Just save this line to a file with a name of your choice and the extension .cmd and you're done. 

    Or save it as a .ps1 file and there's your script. 
    Saturday, October 12, 2019 1:45 PM
  • The diffence is that you cannot double click a .ps1 file by default and because there are no actual Powershell cmdlets it's not necessary.  ... and it would even run in a Powershell console this way.  ;-)

    Live long and prosper!

    (79,108,97,102|%{[char]$_})-join''

    Saturday, October 12, 2019 2:18 PM
  • snifferpro needs to clarify what he's trying to do. He just asked for "a simple script to run the following command using a powershell ps1 file".

    One can always right click on a .ps1 file and select "Run with Powershell". 

    Update 2: there is also the issue that chkdsk needs to be "run as administrator".   
    • Edited by MotoX80 Saturday, October 12, 2019 3:28 PM
    Saturday, October 12, 2019 3:03 PM
  • The question is :I just want to check the health of drive C - I don't want to repair it.".

    For all new Windows users and home users. To get the options of any command in or out of PowerShell just add  -? or /? at the end of the command to see the help for the options.

    chkdsk /?

    Follow the instructions on the screen.

    This has been the way Windows has worked since before Windows as it is the way we did in from the first version of DOS.  It is also the protocol in most computer operating systems.

    I highly recommend that anyone wanting to use a computer should send some time learning the basics of the computer and especially for use of Windows, Mac or Unix systems.  It is also necessary that people read the full user manual for their smartphones and spend time with a book or tutorial on smartphone technology.  This will save you many hours of wasted time.


    \_(ツ)_/

    Saturday, October 12, 2019 3:58 PM