commit f1563c7c04957a4f01770d8051b0e0a59564eacc Author: admin_tan Date: Thu Jun 11 12:13:18 2026 +0200 Téléverser les fichiers vers "/" diff --git a/PowerBGInfoGlobal.zip b/PowerBGInfoGlobal.zip new file mode 100644 index 0000000..7d1018c Binary files /dev/null and b/PowerBGInfoGlobal.zip differ diff --git a/Set-ScheduledTaskPowerBGInfo.ps1 b/Set-ScheduledTaskPowerBGInfo.ps1 new file mode 100644 index 0000000..759d19b --- /dev/null +++ b/Set-ScheduledTaskPowerBGInfo.ps1 @@ -0,0 +1,51 @@ +$TaskName = "IT-Connect_PowerBGInfo_Refresh" + +# 0. La tâche existe-t-elle déjà ? +$ExistingTask = Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue + +if ($ExistingTask) { + Write-Host "La tâche '$TaskName' existe déjà : aucune modification (historique préservé)." -ForegroundColor Yellow + return +} + +# 1. Action - Exécuter le script PowerShell +$Action = New-ScheduledTaskAction -Execute "powershell.exe" ` + -Argument "-WindowStyle Hidden -NoProfile -ExecutionPolicy Bypass -File `"C:\ProgramData\PowerBGInfo\Set-WallpaperPowerBGInfoGlobal.ps1`"" + +# 2. Déclencheur : à l'ouverture de session + répétition toutes les minutes, indéfiniment +$TriggerLogon = New-ScheduledTaskTrigger -AtLogOn + +$Repetition = New-CimInstance -ClassName MSFT_TaskRepetitionPattern ` + -Namespace Root/Microsoft/Windows/TaskScheduler ` + -Property @{ + Interval = "PT5M" + Duration = "P1D" + } -ClientOnly + +$TriggerLogon.Repetition = $Repetition + +# 3. Paramètres +$Settings = New-ScheduledTaskSettingsSet ` + -AllowStartIfOnBatteries ` + -DontStopIfGoingOnBatteries ` + -StartWhenAvailable ` + -MultipleInstances IgnoreNew + +# 4. Contexte utilisateur (groupe "Utilisateurs" via le SID) +$Principal = New-ScheduledTaskPrincipal -GroupId "S-1-5-32-545" -RunLevel Limited + +# 5. Enregistrement la tâche planifiée (pour la créer) +try { + Register-ScheduledTask -TaskName $TaskName ` + -Description "Actualise le fond d'écran dynamique toutes les 5 minutes" ` + -Action $Action ` + -Trigger $TriggerLogon ` + -Settings $Settings ` + -Principal $Principal ` + -ErrorAction Stop | Out-Null + + Write-Host "Tâche '$TaskName' créée avec succès." -ForegroundColor Green +} +catch { + Write-Error "Échec de la création de la tâche : $($_.Exception.Message)" +} \ No newline at end of file diff --git a/Set-WallpaperPowerBGInfoGlobal.ps1 b/Set-WallpaperPowerBGInfoGlobal.ps1 new file mode 100644 index 0000000..11f6ec7 --- /dev/null +++ b/Set-WallpaperPowerBGInfoGlobal.ps1 @@ -0,0 +1,212 @@ +Import-Module PowerBGInfo + +# ==================================================================== +# 1. COLLECTE DYNAMIQUE DES MÉTRIQUES +# ==================================================================== + +# --- DISQUES (DYNAMIQUE) --- +$DiskTiles = @() +$Disks = Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3" | Sort-Object DeviceID + +foreach ($Disk in $Disks) { + if ($Disk.Size -gt 0) { + + $PctFree = [math]::Round(($Disk.FreeSpace / $Disk.Size) * 100, 0) + $Progress = [math]::Round(($Disk.FreeSpace / $Disk.Size), 2) + $TotalGB = [math]::Round($Disk.Size / 1GB, 0) + + if ($PctFree -lt 10) { $Color = '#DC2626FF' } + elseif ($PctFree -lt 25) { $Color = '#F59E0BFF' } + else { $Color = '#16A34AFF' } + + $DiskTiles += New-BGInfoVisualCanvasTile ` + -Side Right ` + -IconKind Storage ` + -SurfaceStyle Raised ` + -Label "DRIVE $($Disk.DeviceID)" ` + -Value "$PctFree% free" ` + -Detail "$TotalGB GB total" ` + -Progress $Progress ` + -Accent $Color + } +} + +# --- CPU --- +$CpuInstances = Get-CimInstance Win32_Processor +$CpuLoad = [math]::Round(($CpuInstances | Measure-Object LoadPercentage -Average).Average, 0) +$TotalCores = ($CpuInstances | Measure-Object NumberOfLogicalProcessors -Sum).Sum + +# --- RAM & OS --- +$OS = Get-CimInstance Win32_OperatingSystem + +$PhysicalRAM = (Get-CimInstance Win32_PhysicalMemory | Measure Capacity -Sum).Sum +$TotalRamGB = [math]::Round($PhysicalRAM / 1GB, 0) + +$UsedRAM_KB = $OS.TotalVisibleMemorySize - $OS.FreePhysicalMemory +$RamUsedGB = [math]::Round(($UsedRAM_KB * 1024) / 1GB, 1) + +# --- OS CLEAN --- +$RawOS = $OS.Caption -replace '^Microsoft\s+', '' +if ($RawOS -match "(.*)\s+(Standard|Datacenter|Professional|Pro|Enterprise|Home|Education|Evaluation)(.*)") { + $OSName = $matches[1].Trim() + $OSEdition = $matches[2].Trim() +} else { + $OSName = $RawOS + $OSEdition = "Edition inconnue" +} +$OSDetail = "$OSEdition - Build $($OS.BuildNumber)" + +# ==================================================================== +# DÉTECTION DES RÔLES +# ==================================================================== + +$Roles = @() + +# AD DS +if (Get-Service NTDS -ErrorAction SilentlyContinue) { + $Roles += "Domain Controler" +} + +# DNS +if (Get-Service DNS -ErrorAction SilentlyContinue) { + $Roles += "DNS" +} + +# DHCP +if (Get-Service DHCPServer -ErrorAction SilentlyContinue) { + $Roles += "DHCP" +} + +# AD CS +if (Get-Service CertSvc -ErrorAction SilentlyContinue) { + $Roles += "Certificate Server" +} + +# IIS +if (Get-Service W3SVC -ErrorAction SilentlyContinue) { + $Roles += "Web Server" +} + +# SQL +if (Get-Service MSSQLSERVER -ErrorAction SilentlyContinue -or + Get-Service | Where-Object {$_.Name -like "MSSQL*"} ) { + $Roles += "SQL" +} + +# File Server (clean) +$SmbShares = Get-SmbShare -ErrorAction SilentlyContinue | Where-Object { + $_.Name -notmatch '^(ADMIN\$|IPC\$|C\$|PRINT\$)' +} + +if ($SmbShares) { + $Roles += "File Server" +} + +# Nettoyage +$Roles = $Roles | Select-Object -Unique + +# Defaut +if ($Roles.Count -eq 0) { + $Roles = @("Generic Server") +} + +$RoleValue = ($Roles -join " / ") +$RoleDetail = "Detected roles" + + +# ==================================================================== +# PATCH STATUS +# ==================================================================== + +$RebootRequired = $false +$UpdatesAvailable = 0 + +# A. Vérification des redémarrages +if (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired") { $RebootRequired = $true } +if (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending") { $RebootRequired = $true } + +# B. Vérification des mises à jour en attente +try { + $UpdateSession = New-Object -ComObject Microsoft.Update.Session + $Searcher = $UpdateSession.CreateUpdateSearcher() + $Searcher.Online = $false + $Result = $Searcher.Search("IsInstalled=0 and IsHidden=0") + $UpdatesAvailable = $Result.Updates.Count +} catch { + $UpdatesAvailable = 0 +} + +# C. Définir les propriétés de la tuile +if ($RebootRequired) { + $PatchValue = "KO - Reboot pending" + $PatchDetail = "Restart required" + $PatchProgress = 0.0 + $PatchColor = '#DC2626FF' +} +elseif ($UpdatesAvailable -gt 0) { + $PatchValue = "WARNING - Updates ready" + $PatchDetail = "$UpdatesAvailable pending install" + $PatchProgress = 0.5 + $PatchColor = '#F59E0BFF' +} +else { + $PatchValue = "OK - Compliant" + $PatchDetail = "Windows is up to date" + $PatchProgress = 1.0 + $PatchColor = '#16A34AFF' +} + +# ==================================================================== +# DESIGN & TUILES +# ==================================================================== + +$palette = @{ + Accent = '#49b1d7FF' + SecondaryAccent = '#ffa340FF' + TitleColor = '#F8FAFCFF' + TitleAccentColor = '#ffa340FF' + SubtitleColor = '#E2E8F0FF' + TileLabelColor = '#475569FF' + TileValueColor = '#0F172AFF' + TileDetailColor = '#334155FF' + TileGlassTop = '#FFF7EDD9' + TileGlassBottom = '#DBEAFECC' + TileProgressTrackColor = '#94A3B8A6' + HeroBadgeTop = '#00698eFF' + HeroBadgeBottom = '#49b1d7FF' + HeroBadgeTextColor = '#FFF7EDFF' +} + +$tiles = @( + # --- GAUCHE --- + New-BGInfoVisualCanvasTile -Side Left -IconKind Computer -SurfaceStyle Raised -Label HOSTNAME -Value '{{HostName}}' -Detail 'Hypervisor' -Accent '#49b1d7FF' + New-BGInfoVisualCanvasTile -Side Left -IconKind Server -SurfaceStyle Raised -Label 'SERVER ROLE' -Value $RoleValue -Detail $RoleDetail -Accent '#ffa340FF' + New-BGInfoVisualCanvasTile -Side Left -IconKind OperatingSystem -SurfaceStyle Raised -Label 'OPERATING SYSTEM' -Value $OSName -Detail $OSDetail -Accent '#00698eFF' + New-BGInfoVisualCanvasTile -Side Left -IconKind Network -SurfaceStyle Raised -Label 'IP ADDRESS' -Value '{{IPv4Address}}' -Detail 'Management IP Address' -Accent '#49b1d7FF' + New-BGInfoVisualCanvasTile -Side Left -IconKind User -SurfaceStyle Raised -Label 'LOGGED USER' -Value '{{UserName}}' -Detail 'Active Session' -Accent '#16A34AFF' + + # --- DROITE --- + New-BGInfoVisualCanvasTile -Side Right -IconKind Cpu -SurfaceStyle Raised -Label 'CPU LOAD' -Value "$CpuLoad% active" -Detail "$TotalCores logical cores" -Accent '#49b1d7FF' + New-BGInfoVisualCanvasTile -Side Right -IconKind Memory -SurfaceStyle Raised -Label 'MEMORY USE' -Value "$RamUsedGB GB used" -Detail "$TotalRamGB GB installed" -Accent '#49b1d7FF' +) + $DiskTiles + @( + New-BGInfoVisualCanvasTile -Side Right -IconKind Shield -SurfaceStyle Raised -Label 'PATCH STATUS' -Value $PatchValue -Detail $PatchDetail -Progress $PatchProgress -Accent $PatchColor +) + +# ==================================================================== +# GÉNÉRATION +# ==================================================================== + +New-BGInfo -MonitorIndex 0 { + + New-BGInfoVisualCanvas ` + -Title 'CORPORATE' ` + -Subtitle 'corpo.up-alios.fr' ` + -FeatureAnchor BottomRight ` + -FeatureWidth 400 ` + -FeatureOffsetX 120 ` + -FeatureOffsetY 120 ` + -Tile $tiles @palette + +} -FilePath "C:\Windows\Web\Wallpaper\Windows\img19-resize.jpg" ` + -WallpaperFit Fill ` + -ConfigurationDirectory "C:\ProgramData\PowerBGInfo" diff --git a/img19-resize.jpg b/img19-resize.jpg new file mode 100644 index 0000000..3afe914 Binary files /dev/null and b/img19-resize.jpg differ