# Commandes Utiles

# DISM

##### Nettoyer WinSXS:

```
dism /online /cleanup-image /startcomponentcleanup /resetbase
```

##### Réparer l'image Windows:

```powershell
DISM /Online /Cleanup-Image /RestoreHealth
```

# Régénerer hibernation file

Pour régénerer l'hibernation file qui peut être cassé:

```
powercfg -off
powercfg -on
```

# Powershell

##### Récupérer l'uptime d'un PC:

```powershell
$OS = Get-CimInstance Win32_OperatingSystem
$Uptime = (Get-Date) - $OS.LastBootUpTime

Write-Host "Dernier démarrage : $($OS.LastBootUpTime)"
Write-Host "Uptime : $($Uptime.Days) jours, $($Uptime.Hours) heures, $($Uptime.Minutes) minutes"
```

##### Vérifier l'état de l'installation de Windows:

```powershell
DISM /Online /Cleanup-Image /ScanHealth
sfc /verifyonly
```

##### Lancer la réparation de Windows:

```powershell
DISM /Online /Cleanup-Image /RestoreHealth
```

Si DISM réussi, on peut lancer:

```powershell
sfc /scannow
```