<# .SYNOPSIS Win11 Style GUI for Microsoft Activation Scripts (MAS) .DESCRIPTION A modern, Fluent-inspired interface for MAS with auto-detection of system status. #> # --- Self-Elevation --- $currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) if (-not $currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { $scriptPath = $MyInvocation.MyCommand.Path Start-Process powershell.exe -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$scriptPath`"" -Verb RunAs Exit } # --- Assemblies --- Add-Type -AssemblyName PresentationFramework Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing # --- Helper: Get System Info --- function Get-SystemInfo { try { $os = Get-CimInstance Win32_OperatingSystem -ErrorAction Stops $comp = Get-CimInstance Win32_ComputerSystem -ErrorAction Stop $edition = $os.Caption -replace "Microsoft ", "" $version = $os.Version $build = $os.BuildNumber # Simple Activation Check (Partial) try { # 1=Licensed $license = Get-CimInstance SoftwareLicensingProduct -ErrorAction SilentlyContinue | Where-Object { $_.PartialProductKey -and $_.Name -like "Windows*" } | Select-Object -First 1 $status = "Unknown / Check manually" if ($null -ne $license) { if ($license.LicenseStatus -eq 1) { $status = "Permanently Activated" if ($license.GracePeriodRemaining -gt 0 -and $license.GracePeriodRemaining -lt 40000) { # KMS usually has grace period in minutes ~ 259200 (180 days) $status = "Volume/KMS Activated" } } else { $status = "Not Activated" } } } catch { $status = "Detection Failed" } return @{ Edition = $edition Version = "Build $build" Status = $status PCName = $comp.Name } } catch { return @{ Edition = "Unknown"; Version = "Unknown"; Status = "Unknown"; PCName = "Unknown" } } } $sysInfo = Get-SystemInfo # --- XAML --- [xml]$xaml = @"