added 2016/2019 server logic
This commit is contained in:
47
kms.ps1
47
kms.ps1
@@ -1,15 +1,3 @@
|
||||
# https://stackoverflow.com/questions/48592120/how-do-i-find-out-from-powershell-if-i-am-on-a-server-or-workstation
|
||||
# $osInfo = Get-WmiObject -Class Win32_OperatingSystem
|
||||
# $osInfo.ProductType
|
||||
# ProductType
|
||||
# Data type: uint32
|
||||
# Access type: Read-only
|
||||
# Additional system information.
|
||||
# Work Station (1)
|
||||
# Domain Controller (2)
|
||||
# Server (3)
|
||||
|
||||
|
||||
#####################
|
||||
# Get Admin Rights ##
|
||||
####################
|
||||
@@ -53,10 +41,23 @@ if ($myWindowsPrincipal.IsInRole($adminRole) -and -not [environment]::Is64BitPro
|
||||
# Set KMS Host
|
||||
c:\Windows\System32\cscript.exe /nologo c:\Windows\System32\slmgr.vbs /skms gauntkms.home.johnhgaunt.com
|
||||
|
||||
$osInfo = Get-WmiObject -Class Win32_OperatingSystem
|
||||
# https://stackoverflow.com/questions/48592120/how-do-i-find-out-from-powershell-if-i-am-on-a-server-or-workstation
|
||||
# $osInfo = Get-WmiObject -Class Win32_OperatingSystem
|
||||
# $osInfo.ProductType
|
||||
# ProductType
|
||||
# Data type: uint32
|
||||
# Access type: Read-only
|
||||
# Additional system information.
|
||||
# Work Station (1)
|
||||
# Domain Controller (2)
|
||||
# Server (3)
|
||||
|
||||
if ($osInfo.ProductType -gt 1) {
|
||||
# Windows 10 Enterprise
|
||||
$osType = Get-WmiObject -Class Win32_OperatingSystem
|
||||
$osInfo = Get-ComputerInfo
|
||||
|
||||
if ($osType.ProductType -gt 1) {
|
||||
|
||||
# Windows 10 Enterprise
|
||||
c:\Windows\System32\cscript.exe /nologo c:\Windows\System32\slmgr.vbs /ipk NPPR9-FWDCX-D2C8J-H872K-2YT43
|
||||
# Windows 10 2016 LTSB
|
||||
#c:\Windows\System32\cscript.exe /nologo c:\Windows\System32\slmgr.vbs /ipk DCPHK-NFMTC-H88MJ-PFHPY-QJ4BJ
|
||||
@@ -65,10 +66,18 @@ if ($osInfo.ProductType -gt 1) {
|
||||
|
||||
|
||||
} else {
|
||||
# Windows Server 2016 Datacenter
|
||||
#c:\Windows\System32\cscript.exe /nologo c:\Windows\System32\slmgr.vbs /ipk CB7KF-BWN84-R7R2Y-793K2-8XDDG
|
||||
# windows Server 2019 Datacenter
|
||||
c:\Windows\System32\cscript.exe /nologo c:\Windows\System32\slmgr.vbs /ipk WMDGN-G9PQG-XVVXX-R3X43-63DFG
|
||||
if ($osInfo.WindowsProductName -eq "Windows Server 2019 DataCenter") {
|
||||
# windows Server 2019 Datacenter
|
||||
c:\Windows\System32\cscript.exe /nologo c:\Windows\System32\slmgr.vbs /ipk WMDGN-G9PQG-XVVXX-R3X43-63DFG
|
||||
} elseif ($osInfo.WindowsProductName -eq "Windows Server 2016 DataCenter") {
|
||||
# Windows Server 2016 Datacenter
|
||||
c:\Windows\System32\cscript.exe /nologo c:\Windows\System32\slmgr.vbs /ipk CB7KF-BWN84-R7R2Y-793K2-8XDDG
|
||||
} else {
|
||||
$message = "Your server version is not supported or could not be detected corrected. Version: $($osInfo.WindowsProductName)"
|
||||
write-error $message
|
||||
exit
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Activate it
|
||||
|
||||
Reference in New Issue
Block a user