Actualiser Set-WallpaperPowerBGInfoGlobal.ps1
This commit is contained in:
+211
-212
@@ -1,212 +1,211 @@
|
|||||||
Import-Module PowerBGInfo
|
Import-Module PowerBGInfo
|
||||||
|
|
||||||
# ====================================================================
|
# ====================================================================
|
||||||
# 1. COLLECTE DYNAMIQUE DES MÉTRIQUES
|
# 1. COLLECTE DYNAMIQUE DES MÉTRIQUES
|
||||||
# ====================================================================
|
# ====================================================================
|
||||||
|
|
||||||
# --- DISQUES (DYNAMIQUE) ---
|
# --- DISQUES (DYNAMIQUE) ---
|
||||||
$DiskTiles = @()
|
$DiskTiles = @()
|
||||||
$Disks = Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3" | Sort-Object DeviceID
|
$Disks = Get-CimInstance Win32_LogicalDisk -Filter "DriveType=3" | Sort-Object DeviceID
|
||||||
|
|
||||||
foreach ($Disk in $Disks) {
|
foreach ($Disk in $Disks) {
|
||||||
if ($Disk.Size -gt 0) {
|
if ($Disk.Size -gt 0) {
|
||||||
|
|
||||||
$PctFree = [math]::Round(($Disk.FreeSpace / $Disk.Size) * 100, 0)
|
$PctFree = [math]::Round(($Disk.FreeSpace / $Disk.Size) * 100, 0)
|
||||||
$Progress = [math]::Round(($Disk.FreeSpace / $Disk.Size), 2)
|
$Progress = [math]::Round(($Disk.FreeSpace / $Disk.Size), 2)
|
||||||
$TotalGB = [math]::Round($Disk.Size / 1GB, 0)
|
$TotalGB = [math]::Round($Disk.Size / 1GB, 0)
|
||||||
|
|
||||||
if ($PctFree -lt 10) { $Color = '#DC2626FF' }
|
if ($PctFree -lt 10) { $Color = '#DC2626FF' }
|
||||||
elseif ($PctFree -lt 25) { $Color = '#F59E0BFF' }
|
elseif ($PctFree -lt 25) { $Color = '#F59E0BFF' }
|
||||||
else { $Color = '#16A34AFF' }
|
else { $Color = '#16A34AFF' }
|
||||||
|
|
||||||
$DiskTiles += New-BGInfoVisualCanvasTile `
|
$DiskTiles += New-BGInfoVisualCanvasTile `
|
||||||
-Side Right `
|
-Side Right `
|
||||||
-IconKind Storage `
|
-IconKind Storage `
|
||||||
-SurfaceStyle Raised `
|
-SurfaceStyle Raised `
|
||||||
-Label "DRIVE $($Disk.DeviceID)" `
|
-Label "DRIVE $($Disk.DeviceID)" `
|
||||||
-Value "$PctFree% free" `
|
-Value "$PctFree% free" `
|
||||||
-Detail "$TotalGB GB total" `
|
-Detail "$TotalGB GB total" `
|
||||||
-Progress $Progress `
|
-Progress $Progress `
|
||||||
-Accent $Color
|
-Accent $Color
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# --- CPU ---
|
# --- CPU ---
|
||||||
$CpuInstances = Get-CimInstance Win32_Processor
|
$CpuInstances = Get-CimInstance Win32_Processor
|
||||||
$CpuLoad = [math]::Round(($CpuInstances | Measure-Object LoadPercentage -Average).Average, 0)
|
$CpuLoad = [math]::Round(($CpuInstances | Measure-Object LoadPercentage -Average).Average, 0)
|
||||||
$TotalCores = ($CpuInstances | Measure-Object NumberOfLogicalProcessors -Sum).Sum
|
$TotalCores = ($CpuInstances | Measure-Object NumberOfLogicalProcessors -Sum).Sum
|
||||||
|
|
||||||
# --- RAM & OS ---
|
# --- RAM & OS ---
|
||||||
$OS = Get-CimInstance Win32_OperatingSystem
|
$OS = Get-CimInstance Win32_OperatingSystem
|
||||||
|
|
||||||
$PhysicalRAM = (Get-CimInstance Win32_PhysicalMemory | Measure Capacity -Sum).Sum
|
$PhysicalRAM = (Get-CimInstance Win32_PhysicalMemory | Measure Capacity -Sum).Sum
|
||||||
$TotalRamGB = [math]::Round($PhysicalRAM / 1GB, 0)
|
$TotalRamGB = [math]::Round($PhysicalRAM / 1GB, 0)
|
||||||
|
|
||||||
$UsedRAM_KB = $OS.TotalVisibleMemorySize - $OS.FreePhysicalMemory
|
$UsedRAM_KB = $OS.TotalVisibleMemorySize - $OS.FreePhysicalMemory
|
||||||
$RamUsedGB = [math]::Round(($UsedRAM_KB * 1024) / 1GB, 1)
|
$RamUsedGB = [math]::Round(($UsedRAM_KB * 1024) / 1GB, 1)
|
||||||
|
|
||||||
# --- OS CLEAN ---
|
# --- OS CLEAN ---
|
||||||
$RawOS = $OS.Caption -replace '^Microsoft\s+', ''
|
$RawOS = $OS.Caption -replace '^Microsoft\s+', ''
|
||||||
if ($RawOS -match "(.*)\s+(Standard|Datacenter|Professional|Pro|Enterprise|Home|Education|Evaluation)(.*)") {
|
if ($RawOS -match "(.*)\s+(Standard|Datacenter|Professional|Pro|Enterprise|Home|Education|Evaluation)(.*)") {
|
||||||
$OSName = $matches[1].Trim()
|
$OSName = $matches[1].Trim()
|
||||||
$OSEdition = $matches[2].Trim()
|
$OSEdition = $matches[2].Trim()
|
||||||
} else {
|
} else {
|
||||||
$OSName = $RawOS
|
$OSName = $RawOS
|
||||||
$OSEdition = "Edition inconnue"
|
$OSEdition = "Edition inconnue"
|
||||||
}
|
}
|
||||||
$OSDetail = "$OSEdition - Build $($OS.BuildNumber)"
|
$OSDetail = "$OSEdition - Build $($OS.BuildNumber)"
|
||||||
|
|
||||||
# ====================================================================
|
# ====================================================================
|
||||||
# DÉTECTION DES RÔLES
|
# DÉTECTION DES RÔLES
|
||||||
# ====================================================================
|
# ====================================================================
|
||||||
|
|
||||||
$Roles = @()
|
$Roles = @()
|
||||||
|
|
||||||
# AD DS
|
# AD DS
|
||||||
if (Get-Service NTDS -ErrorAction SilentlyContinue) {
|
if (Get-Service NTDS -ErrorAction SilentlyContinue) {
|
||||||
$Roles += "Domain Controler"
|
$Roles += "Domain Controler"
|
||||||
}
|
}
|
||||||
|
|
||||||
# DNS
|
# DNS
|
||||||
if (Get-Service DNS -ErrorAction SilentlyContinue) {
|
if (Get-Service DNS -ErrorAction SilentlyContinue) {
|
||||||
$Roles += "DNS"
|
$Roles += "DNS"
|
||||||
}
|
}
|
||||||
|
|
||||||
# DHCP
|
# DHCP
|
||||||
if (Get-Service DHCPServer -ErrorAction SilentlyContinue) {
|
if (Get-Service DHCPServer -ErrorAction SilentlyContinue) {
|
||||||
$Roles += "DHCP"
|
$Roles += "DHCP"
|
||||||
}
|
}
|
||||||
|
|
||||||
# AD CS
|
# AD CS
|
||||||
if (Get-Service CertSvc -ErrorAction SilentlyContinue) {
|
if (Get-Service CertSvc -ErrorAction SilentlyContinue) {
|
||||||
$Roles += "Certificate Server"
|
$Roles += "Certificate Server"
|
||||||
}
|
}
|
||||||
|
|
||||||
# IIS
|
# IIS
|
||||||
if (Get-Service W3SVC -ErrorAction SilentlyContinue) {
|
if (Get-Service W3SVC -ErrorAction SilentlyContinue) {
|
||||||
$Roles += "Web Server"
|
$Roles += "Web Server"
|
||||||
}
|
}
|
||||||
|
|
||||||
# SQL
|
# SQL
|
||||||
if (Get-Service MSSQLSERVER -ErrorAction SilentlyContinue -or
|
if (Get-Service -Name "MSSQL*" -ErrorAction SilentlyContinue) {
|
||||||
Get-Service | Where-Object {$_.Name -like "MSSQL*"} ) {
|
$Roles += "SQL"
|
||||||
$Roles += "SQL"
|
}
|
||||||
}
|
|
||||||
|
# File Server (clean)
|
||||||
# File Server (clean)
|
$SmbShares = Get-SmbShare -ErrorAction SilentlyContinue | Where-Object {
|
||||||
$SmbShares = Get-SmbShare -ErrorAction SilentlyContinue | Where-Object {
|
$_.Name -notmatch '^(ADMIN\$|IPC\$|C\$|PRINT\$)'
|
||||||
$_.Name -notmatch '^(ADMIN\$|IPC\$|C\$|PRINT\$)'
|
}
|
||||||
}
|
|
||||||
|
if ($SmbShares) {
|
||||||
if ($SmbShares) {
|
$Roles += "File Server"
|
||||||
$Roles += "File Server"
|
}
|
||||||
}
|
|
||||||
|
# Nettoyage
|
||||||
# Nettoyage
|
$Roles = $Roles | Select-Object -Unique
|
||||||
$Roles = $Roles | Select-Object -Unique
|
|
||||||
|
# Defaut
|
||||||
# Defaut
|
if ($Roles.Count -eq 0) {
|
||||||
if ($Roles.Count -eq 0) {
|
$Roles = @("Generic Server")
|
||||||
$Roles = @("Generic Server")
|
}
|
||||||
}
|
|
||||||
|
$RoleValue = ($Roles -join " / ")
|
||||||
$RoleValue = ($Roles -join " / ")
|
$RoleDetail = "Detected roles"
|
||||||
$RoleDetail = "Detected roles"
|
|
||||||
|
|
||||||
|
# ====================================================================
|
||||||
# ====================================================================
|
# PATCH STATUS
|
||||||
# PATCH STATUS
|
# ====================================================================
|
||||||
# ====================================================================
|
|
||||||
|
$RebootRequired = $false
|
||||||
$RebootRequired = $false
|
$UpdatesAvailable = 0
|
||||||
$UpdatesAvailable = 0
|
|
||||||
|
# A. Vérification des redémarrages
|
||||||
# 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\WindowsUpdate\Auto Update\RebootRequired") { $RebootRequired = $true }
|
if (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending") { $RebootRequired = $true }
|
||||||
if (Test-Path "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending") { $RebootRequired = $true }
|
|
||||||
|
# B. Vérification des mises à jour en attente
|
||||||
# B. Vérification des mises à jour en attente
|
try {
|
||||||
try {
|
$UpdateSession = New-Object -ComObject Microsoft.Update.Session
|
||||||
$UpdateSession = New-Object -ComObject Microsoft.Update.Session
|
$Searcher = $UpdateSession.CreateUpdateSearcher()
|
||||||
$Searcher = $UpdateSession.CreateUpdateSearcher()
|
$Searcher.Online = $false
|
||||||
$Searcher.Online = $false
|
$Result = $Searcher.Search("IsInstalled=0 and IsHidden=0")
|
||||||
$Result = $Searcher.Search("IsInstalled=0 and IsHidden=0")
|
$UpdatesAvailable = $Result.Updates.Count
|
||||||
$UpdatesAvailable = $Result.Updates.Count
|
} catch {
|
||||||
} catch {
|
$UpdatesAvailable = 0
|
||||||
$UpdatesAvailable = 0
|
}
|
||||||
}
|
|
||||||
|
# C. Définir les propriétés de la tuile
|
||||||
# C. Définir les propriétés de la tuile
|
if ($RebootRequired) {
|
||||||
if ($RebootRequired) {
|
$PatchValue = "KO - Reboot pending"
|
||||||
$PatchValue = "KO - Reboot pending"
|
$PatchDetail = "Restart required"
|
||||||
$PatchDetail = "Restart required"
|
$PatchProgress = 0.0
|
||||||
$PatchProgress = 0.0
|
$PatchColor = '#DC2626FF'
|
||||||
$PatchColor = '#DC2626FF'
|
}
|
||||||
}
|
elseif ($UpdatesAvailable -gt 0) {
|
||||||
elseif ($UpdatesAvailable -gt 0) {
|
$PatchValue = "WARNING - Updates ready"
|
||||||
$PatchValue = "WARNING - Updates ready"
|
$PatchDetail = "$UpdatesAvailable pending install"
|
||||||
$PatchDetail = "$UpdatesAvailable pending install"
|
$PatchProgress = 0.5
|
||||||
$PatchProgress = 0.5
|
$PatchColor = '#F59E0BFF'
|
||||||
$PatchColor = '#F59E0BFF'
|
}
|
||||||
}
|
else {
|
||||||
else {
|
$PatchValue = "OK - Compliant"
|
||||||
$PatchValue = "OK - Compliant"
|
$PatchDetail = "Windows is up to date"
|
||||||
$PatchDetail = "Windows is up to date"
|
$PatchProgress = 1.0
|
||||||
$PatchProgress = 1.0
|
$PatchColor = '#16A34AFF'
|
||||||
$PatchColor = '#16A34AFF'
|
}
|
||||||
}
|
|
||||||
|
# ====================================================================
|
||||||
# ====================================================================
|
# DESIGN & TUILES
|
||||||
# DESIGN & TUILES
|
# ====================================================================
|
||||||
# ====================================================================
|
|
||||||
|
$palette = @{
|
||||||
$palette = @{
|
Accent = '#49b1d7FF'
|
||||||
Accent = '#49b1d7FF'
|
SecondaryAccent = '#ffa340FF'
|
||||||
SecondaryAccent = '#ffa340FF'
|
TitleColor = '#F8FAFCFF'
|
||||||
TitleColor = '#F8FAFCFF'
|
TitleAccentColor = '#ffa340FF'
|
||||||
TitleAccentColor = '#ffa340FF'
|
SubtitleColor = '#E2E8F0FF'
|
||||||
SubtitleColor = '#E2E8F0FF'
|
TileLabelColor = '#475569FF'
|
||||||
TileLabelColor = '#475569FF'
|
TileValueColor = '#0F172AFF'
|
||||||
TileValueColor = '#0F172AFF'
|
TileDetailColor = '#334155FF'
|
||||||
TileDetailColor = '#334155FF'
|
TileGlassTop = '#FFF7EDD9'
|
||||||
TileGlassTop = '#FFF7EDD9'
|
TileGlassBottom = '#DBEAFECC'
|
||||||
TileGlassBottom = '#DBEAFECC'
|
TileProgressTrackColor = '#94A3B8A6'
|
||||||
TileProgressTrackColor = '#94A3B8A6'
|
HeroBadgeTop = '#00698eFF'
|
||||||
HeroBadgeTop = '#00698eFF'
|
HeroBadgeBottom = '#49b1d7FF'
|
||||||
HeroBadgeBottom = '#49b1d7FF'
|
HeroBadgeTextColor = '#FFF7EDFF'
|
||||||
HeroBadgeTextColor = '#FFF7EDFF'
|
}
|
||||||
}
|
|
||||||
|
$tiles = @(
|
||||||
$tiles = @(
|
# --- GAUCHE ---
|
||||||
# --- GAUCHE ---
|
New-BGInfoVisualCanvasTile -Side Left -IconKind Computer -SurfaceStyle Raised -Label HOSTNAME -Value '{{HostName}}' -Detail 'Hypervisor' -Accent '#49b1d7FF'
|
||||||
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 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 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 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'
|
||||||
New-BGInfoVisualCanvasTile -Side Left -IconKind User -SurfaceStyle Raised -Label 'LOGGED USER' -Value '{{UserName}}' -Detail 'Active Session' -Accent '#16A34AFF'
|
|
||||||
|
# --- DROITE ---
|
||||||
# --- 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 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'
|
||||||
New-BGInfoVisualCanvasTile -Side Right -IconKind Memory -SurfaceStyle Raised -Label 'MEMORY USE' -Value "$RamUsedGB GB used" -Detail "$TotalRamGB GB installed" -Accent '#49b1d7FF'
|
) + $DiskTiles + @(
|
||||||
) + $DiskTiles + @(
|
New-BGInfoVisualCanvasTile -Side Right -IconKind Shield -SurfaceStyle Raised -Label 'PATCH STATUS' -Value $PatchValue -Detail $PatchDetail -Progress $PatchProgress -Accent $PatchColor
|
||||||
New-BGInfoVisualCanvasTile -Side Right -IconKind Shield -SurfaceStyle Raised -Label 'PATCH STATUS' -Value $PatchValue -Detail $PatchDetail -Progress $PatchProgress -Accent $PatchColor
|
)
|
||||||
)
|
|
||||||
|
# ====================================================================
|
||||||
# ====================================================================
|
# GÉNÉRATION
|
||||||
# GÉNÉRATION
|
# ====================================================================
|
||||||
# ====================================================================
|
|
||||||
|
New-BGInfo -MonitorIndex 0 {
|
||||||
New-BGInfo -MonitorIndex 0 {
|
|
||||||
|
New-BGInfoVisualCanvas `
|
||||||
New-BGInfoVisualCanvas `
|
-Title 'CORPORATE' `
|
||||||
-Title 'CORPORATE' `
|
-Subtitle 'corpo.up-alios.fr' `
|
||||||
-Subtitle 'corpo.up-alios.fr' `
|
-FeatureAnchor BottomRight `
|
||||||
-FeatureAnchor BottomRight `
|
-FeatureWidth 400 `
|
||||||
-FeatureWidth 400 `
|
-FeatureOffsetX 120 `
|
||||||
-FeatureOffsetX 120 `
|
-FeatureOffsetY 120 `
|
||||||
-FeatureOffsetY 120 `
|
-Tile $tiles @palette
|
||||||
-Tile $tiles @palette
|
|
||||||
|
} -FilePath "C:\Windows\Web\Wallpaper\Windows\img19-resize.jpg" `
|
||||||
} -FilePath "C:\Windows\Web\Wallpaper\Windows\img19-resize.jpg" `
|
-WallpaperFit Fill `
|
||||||
-WallpaperFit Fill `
|
-ConfigurationDirectory "C:\ProgramData\PowerBGInfo"
|
||||||
-ConfigurationDirectory "C:\ProgramData\PowerBGInfo"
|
|
||||||
|
|||||||
Reference in New Issue
Block a user