infos_systeme.ps1

Note de lecture générée automatiquement

Le vrai fichier est scripts/windows/infos_systeme.ps1 (Obsidian n’affiche pas les scripts eux-mêmes). Ne modifie pas cette note : modifie le script, puis relance python3 generer_vues_obsidian.py dans le dossier scripts.

Code

# =============================================================================
# infos_systeme.ps1 — Fiche d'identité d'un poste Windows (PowerShell 5.1 ou 7)
# Usage : clic droit > Exécuter avec PowerShell, ou :  .\infos_systeme.ps1
#         Export : .\infos_systeme.ps1 | Out-File -Encoding utf8 rapport.txt
# =============================================================================
 
function Ecrire-Titre($texte) { Write-Host "`n== $texte ==" -ForegroundColor Cyan }
 
Ecrire-Titre "Système"
$systeme = Get-CimInstance Win32_OperatingSystem
$ordinateur = Get-CimInstance Win32_ComputerSystem
"Nom          : $env:COMPUTERNAME"
"Domaine      : $($ordinateur.Domain)"
"Windows      : $($systeme.Caption) (build $($systeme.BuildNumber))"
"Démarré le   : $($systeme.LastBootUpTime)"
"Utilisateur  : $env:USERDOMAIN\$env:USERNAME"
 
Ecrire-Titre "Matériel"
$processeur = Get-CimInstance Win32_Processor | Select-Object -First 1
"Processeur   : $($processeur.Name.Trim())"
"Cœurs        : $($processeur.NumberOfCores) / threads : $($processeur.NumberOfLogicalProcessors)"
"Mémoire      : {0:N1} Go" -f ($ordinateur.TotalPhysicalMemory / 1GB)
 
Ecrire-Titre "Disques"
Get-Volume | Where-Object DriveLetter |
  Select-Object DriveLetter, FileSystemLabel, FileSystem,
    @{n='Taille (Go)'; e={[math]::Round($_.Size/1GB,1)}},
    @{n='Libre (Go)';  e={[math]::Round($_.SizeRemaining/1GB,1)}} |
  Format-Table -AutoSize
 
Ecrire-Titre "Réseau"
Get-NetIPConfiguration | Where-Object { $_.IPv4Address } |
  Select-Object InterfaceAlias,
    @{n='IPv4';       e={$_.IPv4Address.IPAddress -join ', '}},
    @{n='Passerelle'; e={$_.IPv4DefaultGateway.NextHop}},
    @{n='DNS';        e={$_.DNSServer.ServerAddresses -join ', '}} |
  Format-Table -AutoSize
 
Ecrire-Titre "5 processus les plus gourmands en CPU"
Get-Process | Sort-Object CPU -Descending | Select-Object -First 5 Id, ProcessName,
  @{n='CPU (s)'; e={[math]::Round($_.CPU,1)}},
  @{n='RAM (Mo)'; e={[math]::Round($_.WorkingSet64/1MB)}} | Format-Table -AutoSize
 
Ecrire-Titre "Services automatiques arrêtés"
Get-Service | Where-Object { $_.StartType -eq 'Automatic' -and $_.Status -ne 'Running' } |
  Select-Object Name, DisplayName, Status | Format-Table -AutoSize