Téléverser les fichiers vers "/"

This commit is contained in:
2026-06-11 12:47:29 +02:00
commit fbe24befb0
4 changed files with 302 additions and 0 deletions
+40
View File
@@ -0,0 +1,40 @@
# ============================================================
# LOG
# ============================================================
$LogPath = Join-Path $PSScriptRoot "install.log"
Start-Transcript -Path $LogPath -Append
# ============================================================
# CONFIG
# ============================================================
$BaseUrl = "https://repo.luckyden.org/admin_tan/PowerBGInfoGlobal/raw/branch/main"
$DataPath = "C:\ProgramData\PowerBGInfo"
$WallpaperPath = "$DataPath\img19-resize.jpg"
# ============================================================
# DOSSIERS
# ============================================================
if (!(Test-Path $DataPath)) {
New-Item -ItemType Directory -Path $DataPath -Force
}
# ============================================================
# DOWNLOAD
# ============================================================
Invoke-WebRequest "$BaseUrl/Set-WallpaperPowerBGInfoPCI-COMPLIANT.ps1" -OutFile "$DataPath\Set-WallpaperPowerBGInfoPCI-COMPLIANT.ps1"
Invoke-WebRequest "$BaseUrl/Set-ScheduledTaskPowerBGInfo.ps1" -OutFile "$DataPath\Set-ScheduledTaskPowerBGInfo.ps1"
Invoke-WebRequest "$BaseUrl/img19-resize.jpg" -OutFile $WallpaperPath
# ============================================================
# CREATE SCHEDULED TASK
# ============================================================
& "$DataPath\Set-ScheduledTaskPowerBGInfo.ps1"
# ============================================================
# FIRST RUN
# ============================================================
& "$DataPath\Set-WallpaperPowerBGInfoPCI-COMPLIANT.ps1"
Stop-Transcript
@@ -0,0 +1,51 @@
$TaskName = "PowerBGInfoGlobal_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-WallpaperPowerBGInfoPCI-COMPLIANT.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)"
}
+211
View File
@@ -0,0 +1,211 @@
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 -Name "MSSQL*" -ErrorAction SilentlyContinue) {
$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 'PCI-COMPLIANT' `
-Subtitle 'frslnephsa.local' `
-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"
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 311 KiB