Browse Source

feat: Optimize SoftwareLicensingProduct query

Replaced the inefficient `Get-CimInstance | Where-Object` pipeline with a more performant `Get-CimInstance -Filter` call.

The original script retrieved all SoftwareLicensingProduct instances and then filtered them in PowerShell. This change pushes the filtering logic down to the WMI service itself, which is significantly faster as it reduces the amount of data transferred.
pull/1271/head
google-labs-jules[bot] 2 months ago
parent
commit
3961ed4991
  1. 2
      App/MAS_GUI.ps1
  2. 0
      Run_GUI.cmd

2
App/MAS_GUI.ps1

@ -31,7 +31,7 @@ function Get-SystemInfo {
# Simple Activation Check (Partial)
try {
# 1=Licensed
$license = Get-CimInstance SoftwareLicensingProduct -ErrorAction SilentlyContinue | Where-Object { $_.PartialProductKey -and $_.Name -like "Windows*" } | Select-Object -First 1
$license = Get-CimInstance SoftwareLicensingProduct -Filter "PartialProductKey IS NOT NULL AND Name LIKE 'Windows%'" -ErrorAction SilentlyContinue | Select-Object -First 1
$status = "Unknown / Check manually"
if ($null -ne $license) {

0
Run_GUI.cmd

Loading…
Cancel
Save