Untitled

 avatar
unknown
plain_text
a year ago
2.4 kB
14
Indexable
# ==========================================
# Windows 11 Upgrade - sichtbar & ohne NinjaOne
# ==========================================
$ErrorActionPreference = 'Stop'

# --- Elevation prüfen ---
$IsAdmin = ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()
).IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator)
if (-not $IsAdmin) {
  Start-Process powershell -Verb RunAs -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`""
  exit
}

# Basispfade / Logs
$Base   = "C:\ProgramData\Win11Upgrade"
$CsvLog = Join-Path $Base "Results.csv"
New-Item -ItemType Directory -Path $Base -Force | Out-Null
if (-not (Test-Path $CsvLog)) {
  "ComputerName,User,Timestamp,Phase,Detail,OSCaption,OSVersion" | Out-File -FilePath $CsvLog -Encoding UTF8
}

# --- 1) Grober Kompatibilitätscheck ---
function Test-Win11Ready {
  $minRAMGB = 4; $minDiskGB = 64
  $hasTPM = $false; $secureBoot = $false; $cpu64 = $false
  try { $tpm = Get-WmiObject -Namespace "root\cimv2\Security\MicrosoftTpm" -Class Win32_Tpm -ErrorAction SilentlyContinue; $hasTPM = $tpm -and ($tpm.SpecVersion -match '2\.0') } catch {}
  try { $secureBoot = (Confirm-SecureBootUEFI) -eq $true } catch { $secureBoot = $false }
  try { $cpu64 = ((Get-CimInstance Win32_Processor).AddressWidth -eq 64) } catch { $cpu64 = $false }
  $ramGB  = try {[math]::Round((Get-CimInstance Win32_ComputerSystem).TotalPhysicalMemory/1GB)} catch {0}
  $diskGB = try {[math]::Round((Get-CimInstance Win32_LogicalDisk -Filter "DeviceID='C:'").FreeSpace/1GB)} catch {0}

  [pscustomobject]@{
    Ready      = ($hasTPM -and $secureBoot -and $cpu64 -ge $true -and $ramGB -ge $minRAMGB -and $diskGB -ge $minDiskGB)
    TPM2       = $hasTPM
    SecureBoot = $secureBoot
    CPU64      = $cpu64
    RAMGB      = $ramGB
    FreeC_GB   = $diskGB
  }
}

$compat = Test-Win11Ready
Write-Host ("Kompatibilität: TPM2={0} SecureBoot={1} CPU64={2} RAM={3}GB FreeC={4}GB" -f $compat.TPM2,$compat.SecureBoot,$compat.CPU64,$compat.RAMGB,$compat.FreeC_GB)
if (-not $compat.Ready) {
  "$env:COMPUTERNAME,$env:USERNAME,$(Get-Date -Format s),Blocked,""TPM2=$($compat.TPM2);SecureBoot=$($compat.SecureBoot);RAM=$($compat.RAMGB);FreeC=$($compat.FreeC_GB)"","""",""" | Out-File -FilePath $CsvLog -Append -Encoding UTF8
  throw "Mindestanforderungen nicht erfüllt – Upgrade abgebrochen."
}

# --- 2) Windows
Editor is loading...
Leave a Comment