Windows Server
Windows auf Remotecomputern per PowerShell aktivieren
Mit folgendem Skript aktivierst du einen oder mehrere Remotecomputer per PowerShell. Es installiert den MAK-Key, startet die Aktivierung und gibt anschließend den Lizenzstatus pro Computer zurück.
$Results = Invoke-Command -ComputerName server01 {
# install MAK key
$nullipk = cscript.exe "$env:SystemRoot\System32\slmgr.vbs" /ipk "XXXX-XXXX-XXXX-XXXX-XXXX"
$nullato = cscript.exe "$env:SystemRoot\System32\slmgr.vbs" /ato
# test LicenseStatus
$LicStatus = (((cscript.exe "$env:SystemRoot\System32\slmgr.vbs" /dli) |
Where-Object { $_ -match '\S' })[-1] -split ':', 2)[1].Trim()
# return an object
[PsCustomObject]@{
ComputerName = $env:COMPUTERNAME
LicenseStatus = $LicStatus
}
}
$Results