# Load necessary assemblies Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing # Create the main form $form = New-Object System.Windows.Forms.Form $form.Text = 'EOO, Hulp bij Windows installaties' $form.Size = New-Object System.Drawing.Size(400, 600) $form.StartPosition = 'CenterScreen' # Windows Version Label $lblWindowsVersion = New-Object System.Windows.Forms.Label $lblWindowsVersion.Location = New-Object System.Drawing.Point(50, 120) $lblWindowsVersion.Size = New-Object System.Drawing.Size(300, 30) $form.Controls.Add($lblWindowsVersion) # Activation State Label $lblActivationState = New-Object System.Windows.Forms.Label $lblActivationState.Location = New-Object System.Drawing.Point(50, 150) $lblActivationState.Size = New-Object System.Drawing.Size(300, 30) $form.Controls.Add($lblActivationState) # TPM Status Label $lblTpmStatus = New-Object System.Windows.Forms.Label $lblTpmStatus.Location = New-Object System.Drawing.Point(50, 180) $lblTpmStatus.Size = New-Object System.Drawing.Size(300, 30) $form.Controls.Add($lblTpmStatus) # Secure Boot Status Label $lblSecureBootStatus = New-Object System.Windows.Forms.Label $lblSecureBootStatus.Location = New-Object System.Drawing.Point(50, 210) $lblSecureBootStatus.Size = New-Object System.Drawing.Size(300, 30) $form.Controls.Add($lblSecureBootStatus) # Function to display Windows version and build number function Display-WindowsVersion { $osInfo = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' $productName = $osInfo.ProductName $displayVersion = $osInfo.DisplayVersion $buildNumber = [int]$osInfo.CurrentBuildNumber # Adjust for Windows 11 if ($buildNumber -ge 22000) { $productName = $productName -replace '10', '11' } $lblWindowsVersion.Text = "Windows Version: $productName $displayVersion (Build $buildNumber)" } # Function to display activation status function Display-ActivationStatus { $licenseStatus = Get-CimInstance -Query "SELECT LicenseStatus FROM SoftwareLicensingProduct WHERE PartialProductKey IS NOT NULL AND LicenseStatus=1" if ($licenseStatus) { $lblActivationState.Text = 'Activation State: Activated' } else { $lblActivationState.Text = 'Activation State: Not Activated' } } # Function to display TPM status function Display-TpmStatus { try { $tpm = Get-WmiObject -Namespace 'Root\CIMv2\Security\MicrosoftTpm' -Class Win32_Tpm if ($tpm) { $specVersion = $tpm.SpecVersion if ($specVersion) { $lblTpmStatus.Text = "TPM Status: Enabled (Version $specVersion)" } else { $lblTpmStatus.Text = 'TPM Status: Enabled (Version information not available)' } } else { $lblTpmStatus.Text = 'TPM Status: Not Enabled' } } catch { $lblTpmStatus.Text = 'TPM Status: Error retrieving information' } } # Function to display Secure Boot status function Display-SecureBootStatus { try { if (Get-Command -Name 'Confirm-SecureBootUEFI' -ErrorAction SilentlyContinue) { $secureBootStatus = Confirm-SecureBootUEFI if ($secureBootStatus) { $lblSecureBootStatus.Text = 'Secure Boot Status: Enabled' } else { $lblSecureBootStatus.Text = 'Secure Boot Status: Disabled' } } else { $lblSecureBootStatus.Text = 'Secure Boot Status: Cmdlet not supported on this platform' } } catch { $lblSecureBootStatus.Text = 'Secure Boot Status: Error retrieving information' } } # Restart Button $btnRestart = New-Object System.Windows.Forms.Button $btnRestart.Location = New-Object System.Drawing.Point(50, 250) $btnRestart.Size = New-Object System.Drawing.Size(100, 30) $btnRestart.Text = 'Restart' $btnRestart.Add_Click({ Start-Process PowerShell -ArgumentList '-Command shutdown.exe /r /t 0' -NoNewWindow }) $form.Controls.Add($btnRestart) # Shutdown Button $btnShutdown = New-Object System.Windows.Forms.Button $btnShutdown.Location = New-Object System.Drawing.Point(200, 250) $btnShutdown.Size = New-Object System.Drawing.Size(100, 30) $btnShutdown.Text = 'Shutdown' $btnShutdown.Add_Click({ Start-Process PowerShell -ArgumentList '-Command shutdown.exe /s /t 0' -NoNewWindow }) $form.Controls.Add($btnShutdown) # Open Windows Update Settings Button $btnWindowsUpdates = New-Object System.Windows.Forms.Button $btnWindowsUpdates.Location = New-Object System.Drawing.Point(50, 290) $btnWindowsUpdates.Size = New-Object System.Drawing.Size(250, 30) $btnWindowsUpdates.Text = 'Open Windows Update' $btnWindowsUpdates.Add_Click({ Start-Process 'ms-settings:windowsupdate' }) $form.Controls.Add($btnWindowsUpdates) # Install HP Updates Button (Opens a Separate PowerShell Window) $btnHpUpdates = New-Object System.Windows.Forms.Button $btnHpUpdates.Location = New-Object System.Drawing.Point(50, 330) $btnHpUpdates.Size = New-Object System.Drawing.Size(250, 30) $btnHpUpdates.Text = 'Install HP Updates' $btnHpUpdates.Add_Click({ # Define PowerShell script to run $PowerShellCommand = "irm https://pc.eoo.support/updatehp.ps1 | iex; pause" # Open a new PowerShell window and execute the command Start-Process "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -Command `"$PowerShellCommand`"" -WindowStyle Normal }) $form.Controls.Add($btnHpUpdates) # Open Device Manager Button $btnOpenDeviceManager = New-Object System.Windows.Forms.Button $btnOpenDeviceManager.Location = New-Object System.Drawing.Point(50, 370) $btnOpenDeviceManager.Size = New-Object System.Drawing.Size(250, 30) $btnOpenDeviceManager.Text = 'Open Device Manager' $btnOpenDeviceManager.Add_Click({ Start-Process 'devmgmt.msc' }) $form.Controls.Add($btnOpenDeviceManager) # Activate Windows Button $btnActivateWindows = New-Object System.Windows.Forms.Button $btnActivateWindows.Location = New-Object System.Drawing.Point(50, 410) $btnActivateWindows.Size = New-Object System.Drawing.Size(250, 30) $btnActivateWindows.Text = 'Activate Windows' $btnActivateWindows.Add_Click({ Start-Process "C:\Windows\System32\slui.exe" }) $form.Controls.Add($btnActivateWindows) # Initialize the form and display system info Display-WindowsVersion Display-ActivationStatus Display-TpmStatus Display-SecureBootStatus # Show the form [void]$form.ShowDialog()