From d6f72c7ce70dc75d23198dd908bb78ed1091875f Mon Sep 17 00:00:00 2001 From: jgaunt Date: Tue, 22 Oct 2019 16:52:42 -0400 Subject: [PATCH] Update 'kms.ps1' --- kms.ps1 | 59 ++++++++++++++++++++++++++++++++++----------------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/kms.ps1 b/kms.ps1 index 04782aa..823ce82 100644 --- a/kms.ps1 +++ b/kms.ps1 @@ -1,31 +1,42 @@ -# Windows OS -# Set KMS Host -c:\Windows\System32\cscript.exe /nologo c:\Windows\System32\slmgr.vbs /skms gauntkms.home.johnhgaunt.com -# 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 -# 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 -# Activate it -c:\Windows\System32\cscript.exe /nologo c:\Windows\System32\slmgr.vbs /ato - -# Office 2019 -c:\Windows\System32\cscript.exe /nologo "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /inpkey:NMMKJ-6RK4F-KMJVX-8D9MJ-6MWKP -# Set KMS Host -c:\Windows\System32\cscript.exe /nologo "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /sethst:gauntkms.home.johnhgaunt.com -# Activate it -c:\Windows\System32\cscript.exe /nologo "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /act - # 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 +# $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) \ No newline at end of file +# Server (3) + + +# Windows OS +# 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 + +if ($osInfo.ProductType -gt 1) { + # 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 + +} else { + # 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 +} + +# Activate it +c:\Windows\System32\cscript.exe /nologo c:\Windows\System32\slmgr.vbs /ato + +if (test-path "C:\Program Files\Microsoft Office\Office16\ospp.vbs") { + # Office 2019 + c:\Windows\System32\cscript.exe /nologo "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /inpkey:NMMKJ-6RK4F-KMJVX-8D9MJ-6MWKP + # Set KMS Host + c:\Windows\System32\cscript.exe /nologo "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /sethst:gauntkms.home.johnhgaunt.com + # Activate it + c:\Windows\System32\cscript.exe /nologo "C:\Program Files\Microsoft Office\Office16\ospp.vbs" /act +} \ No newline at end of file