Skip to content

Instantly share code, notes, and snippets.

@jonimattila
Created January 8, 2020 07:36
Show Gist options
  • Save jonimattila/d34c1ec74ffb7dc99bd6326ae8929e05 to your computer and use it in GitHub Desktop.
Save jonimattila/d34c1ec74ffb7dc99bd6326ae8929e05 to your computer and use it in GitHub Desktop.

Revisions

  1. jonimattila created this gist Jan 8, 2020.
    6 changes: 6 additions & 0 deletions Windows_ImageHealthState_fix.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    Start-Process -FilePath "${env:Windir}\System32\SFC.EXE" -ArgumentList '/scannow' -Wait -Verb RunAs
    Repair-WindowsImage -Online -scanhealth
    Repair-WindowsImage -Online -checkhealth
    if ($ComputerProperties = Repair-WindowsImage -Online -checkhealth | Select-Object ImageHealthState | Where-Object {($_.ImageHealthState -notlike "Healthy")}) {
    Repair-WindowsImage -Online -RestoreHealth}
    Start-Process -FilePath "${env:Windir}\System32\SFC.EXE" -ArgumentList '/scannow' -Wait -Verb RunAs