$servers = @" itdcjissqlt1.nd.gov itddlmacpt1.nd.gov itddlmdev1.nd.gov itddlmsit1.nd.gov itddlmtrng1.nd.gov itddlmuat1.nd.gov itdnett1.nd.gov itdombnett1.nd.gov "@ $servers = ConvertTo-Array -MultiLineString $servers Invoke-Command -ComputerName $servers -Credential $AdminCred -scriptblock {Get-Process ccmexec,ccmsetup -ErrorAction SilentlyContinue} # validation $ESUbool = $false $KMSbool = $false $OS = (Get-WMIObject Win32_OperatingSystem).Caption write-verbose $OS switch ($OS) { 'Microsoft Windows Server 2008 R2 Datacenter ' { write-verbose "switch datacenter edition" $KMSId = '7482e61b-c589-4b7f-8ecc-46d455ac3b87' $KMSClientKey = '74YFP-3QFB3-KQT8W-PMXWJ-7M648' $ESUId = '553673ed-6ddf-419c-a153-b760283472fd' } 'Microsoft Windows Server 2008 R2 Enterprise ' { write-verbose "switch enterprise edition" $KMSId = '620e2b3d-09e7-42fd-802a-17a13652fe7a' $KMSClientKey = '489J6-VHDMP-X63PK-3K798-CPX3Y' $ESUId = '553673ed-6ddf-419c-a153-b760283472fd' } 'Microsoft Windows Server 2008 R2 Standard ' { write-verbose "switch standard edition" $KMSId = '' $KMSClientKey = 'YC6KT-GKW9T-YTKYR-T4X34-R7VHC' $ESUId = '553673ed-6ddf-419c-a153-b760283472fd' } 'Microsoft Windows 7 Enterprise '{ write-verbose "switch Win7 enterprise edition" $KMSId = 'ae2ee509-1b34-41c0-acb7-6d4650168915' $KMSClientKey = 'YC6KT-GKW9T-YTKYR-T4X34-R7VHC' $ESUId = '77db037b-95c3-48d7-a3ab-a9c6d41093e0' } 'Microsoft® Windows Server® 2008 Standard '{ write-verbose "switch Win7 enterprise edition" $KMSId = 'ad2542d4-9154-4c6d-8a44-30f11ee96989' $KMSClientKey = 'TM24T-X9RMF-VWXK6-X8JC9-BFGM2' $ESUId = '553673ed-6ddf-419c-a153-b760283472fd' } } $software = Get-WMIObject -Class SoftwareLicensingProduct $ESUYear1 = $software | Where-Object { $_.Id -eq $ESUId } If ($ESUYear1) { If ($ESUYear1.LicenseStatus -eq '1') { $ESUbool = $true } } $KMS = $software | where-object { $_.Id -eq $KMSId } If ($KMS) { If ($KMS.LicenseStatus -eq 1) { $KMSbool = $true } } If ($ESUbool -eq $true -and $KMSbool -eq $true) { $compliant = $true } else { $compliant = $false } $compliant #remediation $OS = (Get-WMIObject Win32_OperatingSystem).Caption switch ($OS) { 'Microsoft Windows Server 2008 R2 Datacenter ' { write-verbose "switch datacenter edition" $KMSId = '7482e61b-c589-4b7f-8ecc-46d455ac3b87' $KMSClientKey = '74YFP-3QFB3-KQT8W-PMXWJ-7M648' $ESUKey = 'MMFTT-7FBRY-W9QYW-37FMB-TRPJK' $ESUId = '553673ed-6ddf-419c-a153-b760283472fd' } 'Microsoft Windows Server 2008 R2 Enterprise ' { write-verbose "switch enterprise edition" $KMSId = '' $KMSClientKey = '489J6-VHDMP-X63PK-3K798-CPX3Y' $ESUKey = 'MMFTT-7FBRY-W9QYW-37FMB-TRPJK' $ESUId = '553673ed-6ddf-419c-a153-b760283472fd' } 'Microsoft Windows Server 2008 R2 Standard ' { write-verbose "switch standard edition" $KMSId = '' $KMSClientKey = 'YC6KT-GKW9T-YTKYR-T4X34-R7VHC' $ESUKey = 'MMFTT-7FBRY-W9QYW-37FMB-TRPJK' $ESUId = '553673ed-6ddf-419c-a153-b760283472fd' } 'Microsoft Windows 7 Enterprise ' { write-verbose "switch Win7 Enterprise" $KMSId = 'ae2ee509-1b34-41c0-acb7-6d4650168915' $KMSClientKey = '33PXH-7Y6KF-2VJC9-XBBR8-HVTHH' $ESUKey = 'MJCJ8-24DFX-VGK6H-XYBQ7-F6PR8' $ESUId = '77db037b-95c3-48d7-a3ab-a9c6d41093e0' } 'Microsoft® Windows Server® 2008 Standard '{ write-verbose "switch Win7 enterprise edition" $KMSId = 'ad2542d4-9154-4c6d-8a44-30f11ee96989' $KMSClientKey = 'TM24T-X9RMF-VWXK6-X8JC9-BFGM2' $ESUKey = 'MMFTT-7FBRY-W9QYW-37FMB-TRPJK' $ESUId = '553673ed-6ddf-419c-a153-b760283472fd' } } cscript C:\Windows\System32\slmgr.vbs -ipk $KMSClientKey cscript C:\Windows\System32\slmgr.vbs -skms itdkms2.nd.gov cscript C:\Windows\System32\slmgr.vbs -ato $KMSId cscript C:\Windows\System32\slmgr.vbs -ipk $ESUKey cscript C:\Windows\System32\slmgr.vbs -ato $ESUId cscript C:\windows\system32\slmgr.vbs /dlv