PowerShell and Windows 11 commands
Windows 11 troubleshooting and administration commands, in PowerShell and CMD. Each entry states its risk level: read-only, changes the system, or needs an elevated prompt (administrator).
Results
Commands marked 'Needs admin' must be run in a terminal opened 'as administrator'. Read the description before running a command that changes the system.
Full list
Show all 58 entries
sfc /scannowsfc /scannowChecks protected system files and replaces corrupted ones.
sfc /scannow sfc /verifyonlyDISM /RestoreHealthDISM /Online /Cleanup-Image /RestoreHealthRepairs the running Windows image from Windows Update or a source.
DISM /Online /Cleanup-Image /CheckHealth DISM /Online /Cleanup-Image /ScanHealth DISM /Online /Cleanup-Image /RestoreHealth DISM /Online /Cleanup-Image /RestoreHealth /Source:wim:D:\sources\install.wim:1 /LimitAccesschkdskchkdsk <drive>: [/f] [/r] [/scan]Checks a volume's file system and fixes errors.
chkdsk C: /scan chkdsk C: /f /r Repair-Volume -DriveLetter C -Scansysteminfosysteminfo [/s <computer>]Shows the Windows version, hardware, memory, installed fixes and domain.
systeminfo systeminfo | findstr /B /C:"Nom de l'hôte" /C:"Nom du système d'exploitation"Get-ComputerInfoGet-ComputerInfo [-Property <list>]Detailed system information as a PowerShell object.
Get-ComputerInfo -Property WindowsProductName,WindowsVersion,OsBuildNumber,CsTotalPhysicalMemory (Get-ComputerInfo).OsLastBootUpTimewinver / Get-CimInstance Win32_OperatingSystemGet-CimInstance Win32_OperatingSystem | Select Caption,Version,BuildNumberWindows version and build.
winver Get-CimInstance Win32_OperatingSystem | Select Caption,Version,BuildNumber,LastBootUpTimehostname / Rename-ComputerRename-Computer -NewName <name> -RestartShows or changes the machine name.
hostname Rename-Computer -NewName PC-COMPTA-01 -RestartRestart-Computer / shutdownshutdown /r /t 0 | Restart-Computer -ForceRestarts or shuts down the machine, locally or remotely.
shutdown /r /t 60 /c "Redémarrage de maintenance" shutdown /a Restart-Computer -ComputerName PC01 -ForceGet-HotFixGet-HotFix [-Id <KB>]Lists installed fixes (KB).
Get-HotFix | Sort-Object InstalledOn -Descending | Select -First 10 Get-HotFix -Id KB5034123winget upgradewinget upgrade [--all] [--id <id>]Lists or installs updates for applications managed by winget.
winget upgrade winget upgrade --all --include-unknown --accept-package-agreements --accept-source-agreements winget upgrade --id Mozilla.Firefoxwinget installwinget install <name> | --id <id> [-e] [--silent]Installs an application from the winget sources.
winget search vscode winget install --id Microsoft.VisualStudioCode -e --silent winget uninstall --id Microsoft.VisualStudioCodeGet-WindowsUpdateLogGet-WindowsUpdateLog [-LogPath <file>]Generates a readable Windows Update log from the ETL traces.
Get-WindowsUpdateLog -LogPath $env:USERPROFILE\Desktop\WindowsUpdate.logusoclient / wuaucltUsoClient StartScan | StartDownload | StartInstallTriggers update scan or installation from the command line (not officially documented).
UsoClient StartScan UsoClient StartDownload UsoClient StartInstallGet-ChildItemGet-ChildItem [-Path <path>] [-Recurse] [-Filter <pattern>] [-Force]Lists files and folders, optionally recursively.
Get-ChildItem C:\Logs -Recurse -Filter *.log | Where-Object Length -gt 100MB gci -Force -File | Sort-Object LastWriteTime -Descending | Select -First 10Get-ItemGet-Item <path>Reads a file, folder or registry key (properties, attributes, dates).
Get-Item C:\Windows\System32\notepad.exe | Select Name,Length,LastWriteTime,VersionInfo Get-Item HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersionGet-ContentGet-Content <file> [-Tail <n>] [-Wait]Reads a text file, including continuous follow (like tail -f).
Get-Content C:\Logs\app.log -Tail 50 -Wait Get-Content liste.txt | Select-String 'erreur'Select-StringSelect-String -Pattern <regex> -Path <files>Searches for a pattern in files or a stream (PowerShell grep).
Select-String -Path C:\Logs\*.log -Pattern 'ERROR|FATAL' -CaseSensitive Get-ChildItem -Recurse *.ps1 | Select-String 'Invoke-Expression'robocopyrobocopy <source> <destination> [files] [options]Robust folder copy (resume, multithread, mirror, permissions).
robocopy D:\Donnees E:\Sauvegarde /E /COPY:DAT /R:2 /W:5 /MT:16 /LOG:C:\Temp\robocopy.log robocopy D:\Donnees E:\Sauvegarde /MIR /XD .git /LCopy-Item / Move-Item / Remove-ItemCopy-Item <source> <destination> [-Recurse]Copies, moves or deletes files and folders.
Copy-Item C:\Src\* D:\Dest -Recurse Remove-Item C:\Temp\vieux -Recurse -Force -WhatIficaclsicacls <path> [/grant|/deny|/remove|/reset] [/T]Shows or changes the NTFS permissions of a file or folder.
icacls D:\Partage icacls D:\Partage /grant "DOMAINE\Groupe":(OI)(CI)M /T icacls D:\Partage /reset /TGet-AclGet-Acl <chemin>Reads the permissions of a file, folder or registry key.
(Get-Acl D:\Partage).Access | Select IdentityReference,FileSystemRights,AccessControlTypeGet-ProcessGet-Process [-Name <name>] [-Id <pid>]Lists running processes (memory, CPU, path).
Get-Process | Sort-Object WS -Descending | Select -First 10 Name,Id,@{n='MémoireMo';e={[int]($_.WS/1MB)}} Get-Process -Name chrome | Stop-Process -WhatIfStop-Process / taskkillStop-Process -Name <name> -Force | taskkill /IM <exe> /FTerminates a process.
Stop-Process -Id 1234 -Force taskkill /IM notepad.exe /F taskkill /PID 1234 /T /Ftasklisttasklist [/svc] [/fi "<filter>"]Lists processes with, optionally, the services they host.
tasklist /svc tasklist /fi "imagename eq svchost.exe" /svc tasklist /fi "memusage gt 500000"Get-ServiceGet-Service [-Name <name>]Lists services and their state.
Get-Service | Where-Object { $_.Status -eq 'Running' -and $_.StartType -eq 'Automatic' } Get-Service wuauserv,bits | Format-Table Name,Status,StartTypeRestart-Service / Set-ServiceRestart-Service <name> | Set-Service <name> -StartupType DisabledRestarts a service or changes its startup type.
Restart-Service Spooler -Force Set-Service -Name wuauserv -StartupType Manual net stop spooler && net start spoolerGet-CimInstance Win32_ProcessGet-CimInstance Win32_Process | Select Name,ProcessId,CommandLineProcesses with full command line and parent.
Get-CimInstance Win32_Process -Filter "Name='powershell.exe'" | Select ProcessId,ParentProcessId,CommandLineipconfigipconfig [/all] [/release] [/renew] [/flushdns] [/displaydns]Shows the IP configuration and manages the DNS cache and DHCP lease.
ipconfig /all ipconfig /flushdns ipconfig /release && ipconfig /renewTest-NetConnectionTest-NetConnection <host> [-Port <port>] [-TraceRoute]Tests connectivity (ping, TCP port, route).
Test-NetConnection google.com -Port 443 Test-NetConnection 10.0.0.1 -TraceRoute tnc smtp.office365.com -Port 587 -InformationLevel QuietGet-NetAdapterGet-NetAdapter [-Name <name>]Lists network adapters, their state, speed and MAC address.
Get-NetAdapter | Select Name,Status,LinkSpeed,MacAddress Restart-NetAdapter -Name 'Ethernet' Disable-NetAdapter -Name 'Wi-Fi' -Confirm:$falseGet-NetIPAddress / Get-NetIPConfigurationGet-NetIPConfiguration [-Detailed]IP addresses, gateway and DNS of each interface.
Get-NetIPConfiguration Get-NetIPAddress -AddressFamily IPv4 | Select InterfaceAlias,IPAddress,PrefixLengthResolve-DnsNameResolve-DnsName <name> [-Type <type>] [-Server <dns>]Queries DNS (A, MX, TXT, CNAME…) without nslookup.
Resolve-DnsName contoso.com -Type MX Resolve-DnsName contoso.com -Type TXT -Server 1.1.1.1Get-NetTCPConnectionGet-NetTCPConnection [-State Listen] [-LocalPort <port>]TCP connections and listening ports, with the owning process.
Get-NetTCPConnection -State Listen | Select LocalAddress,LocalPort,OwningProcess Get-Process -Id (Get-NetTCPConnection -LocalPort 443).OwningProcessnetshnetsh <context> <command>Network configuration tool (Wi-Fi, firewall, proxy, stack reset).
netsh wlan show profiles netsh wlan show profile name="MonWifi" key=clear netsh winsock reset netsh int ip reset netsh advfirewall show allprofilesping / tracert / pathpingping <host> [-n <count>] [-t] | tracert <host> | pathping <host>Tests reachability and the network path to a host.
ping -n 4 8.8.8.8 ping -t 192.168.1.1 tracert -d contoso.com pathping -q 10 contoso.comGet-Disk / Get-VolumeGet-Disk | Get-Partition | Get-VolumePhysical disks, partitions and volumes (size, free space, health).
Get-Disk | Select Number,FriendlyName,Size,HealthStatus,PartitionStyle Get-Volume | Select DriveLetter,FileSystemLabel,FileSystem,@{n='LibreGo';e={[math]::Round($_.SizeRemaining/1GB,1)}}Get-PhysicalDiskGet-PhysicalDisk | Get-StorageReliabilityCounterDisk health state and reliability counters (simplified SMART).
Get-PhysicalDisk | Select FriendlyName,MediaType,HealthStatus,OperationalStatus Get-PhysicalDisk | Get-StorageReliabilityCounter | Select Temperature,Wear,ReadErrorsTotalcleanmgr / Storage Sensecleanmgr /sageset:1 ; cleanmgr /sagerun:1Disk cleanup driven by a saved profile.
cleanmgr /sageset:1 cleanmgr /sagerun:1 Get-ChildItem $env:TEMP -Recurse -Force | Remove-Item -Recurse -Force -WhatIfdiskpartdiskpart > list disk | select disk <n> | clean | create partition primaryAdvanced management of disks and partitions in interactive mode.
diskpart list disk select disk 1 list partitionGet-LocalUserGet-LocalUser [-Name <name>]Lists local accounts and their state.
Get-LocalUser | Select Name,Enabled,LastLogon,PasswordLastSet Disable-LocalUser -Name 'invite' New-LocalUser -Name 'support' -NoPasswordAdd-LocalGroupMemberAdd-LocalGroupMember -Group <group> -Member <account>Adds an account to a local group (for example Administrators).
Get-LocalGroupMember Administrateurs Add-LocalGroupMember -Group 'Administrateurs' -Member 'DOMAINE\jdupont' net localgroup Administrateurs jdupont /addwhoamiwhoami [/groups] [/priv] [/all]Shows the current user, their groups and privileges.
whoami whoami /groups whoami /privnet usernet user [<account> [<password>] [/add] [/domain]]Manages local user accounts (or domain accounts with /domain).
net user net user jdupont net user jdupont /domain net accountsmanage-bdemanage-bde -status | -protectors -get <drive>: | -on <drive>:BitLocker state and management on the command line.
manage-bde -status manage-bde -protectors -get C: manage-bde -on C: -RecoveryPasswordGet-BitLockerVolumeGet-BitLockerVolume [-MountPoint <drive>]BitLocker encryption state and protectors of each volume.
Get-BitLockerVolume | Select MountPoint,VolumeStatus,ProtectionStatus,EncryptionPercentage (Get-BitLockerVolume -MountPoint C:).KeyProtector | Where KeyProtectorType -eq RecoveryPassword BackupToAAD-BitLockerKeyProtector -MountPoint C: -KeyProtectorId '{GUID}'Get-MpComputerStatus / Start-MpScanGet-MpComputerStatus ; Start-MpScan -ScanType QuickScanMicrosoft Defender Antivirus state and starting a scan.
Get-MpComputerStatus | Select AntivirusEnabled,RealTimeProtectionEnabled,AntivirusSignatureLastUpdated Update-MpSignature Start-MpScan -ScanType FullScangpupdategpupdate [/force] [/target:computer|user]Applies group policies immediately.
gpupdate /force gpupdate /target:computer /forcegpresultgpresult /r | /h <file.html> [/scope computer|user]Shows the group policies actually applied to the machine and the user.
gpresult /r gpresult /h C:\Temp\gpo.html /f gpresult /scope computer /vGet-NetFirewallRuleGet-NetFirewallRule [-DisplayName <name>] | New-NetFirewallRuleLists or creates Windows Defender Firewall rules.
Get-NetFirewallRule -Enabled True -Direction Inbound | Select DisplayName,Action,Profile New-NetFirewallRule -DisplayName 'Autoriser TCP 8080' -Direction Inbound -Protocol TCP -LocalPort 8080 -Action AllowGet-ExecutionPolicy / Set-ExecutionPolicyGet-ExecutionPolicy -ListThe PowerShell script execution policy.
Get-ExecutionPolicy -List Set-ExecutionPolicy RemoteSigned -Scope CurrentUserGet-WinEventGet-WinEvent -LogName <log> [-MaxEvents <n>] [-FilterHashtable @{...}]Reads Windows event logs, with efficient filtering.
Get-WinEvent -LogName System -MaxEvents 20 | Select TimeCreated,Id,LevelDisplayName,Message Get-WinEvent -FilterHashtable @{LogName='Security'; Id=4625; StartTime=(Get-Date).AddHours(-24)} Get-WinEvent -ListLog * | Where RecordCount -gt 0 | Sort RecordCount -Descending | Select -First 10 LogName,RecordCountwevtutilwevtutil qe <log> /c:<n> /rd:true /f:textQueries, exports or clears an event log.
wevtutil qe System /c:10 /rd:true /f:text wevtutil epl Security C:\Temp\security.evtx wevtutil cl ApplicationGet-EventLogGet-EventLog -LogName System -Newest <n>Old reading of the classic logs (Windows PowerShell 5.1 only).
Get-EventLog -LogName Application -EntryType Error -Newest 20Get-CimInstance Win32_ReliabilityRecordsGet-CimInstance Win32_ReliabilityRecords | Select -First 20Reliability history (crashes, installation failures) as in Reliability Monitor.
Get-CimInstance Win32_ReliabilityRecords | Where SourceName -eq 'Application Error' | Select TimeGenerated,ProductName,Message -First 10Reset-ComputerMachinePassword / Test-ComputerSecureChannelTest-ComputerSecureChannel -Repair -Credential <compte>Checks and repairs the trust relationship between the machine and the domain.
Test-ComputerSecureChannel -Verbose Test-ComputerSecureChannel -Repair -Credential (Get-Credential)dsregcmd /statusdsregcmd /statusState of the Entra ID / hybrid join and of the authentication token (PRT).
dsregcmd /status dsregcmd /status | findstr /i "AzureAdJoined DomainJoined AzureAdPrt"Reset Windows Update (services and cache)net stop wuauserv, bits ; rename SoftwareDistribution ; net startClassic procedure when Windows Update stays stuck.
net stop wuauserv && net stop bits ren C:\Windows\SoftwareDistribution SoftwareDistribution.old net start bits && net start wuauservpowercfg /batteryreportpowercfg /batteryreport | /energy | /requestsBattery report, energy diagnostics, and what prevents sleep.
powercfg /batteryreport /output C:\Temp\batterie.html powercfg /energy powercfg /requests powercfg /a