83 lines
2.0 KiB
PowerShell
83 lines
2.0 KiB
PowerShell
#MAK & ESU discovery v3
|
|
|
|
$Esu1Bool = $false
|
|
$Esu2Bool = $false
|
|
$Esu3Bool = $false
|
|
$MakBool = $false
|
|
|
|
$OS = (Get-WmiObject Win32_OperatingSystem).Caption
|
|
Write-Verbose $OS
|
|
|
|
$Esu1Key = '4RPR3-NRF26-9CTKB-7GRXQ-GF72Q'
|
|
$Esu2Key = $null
|
|
$Esu3Key = $null
|
|
|
|
# activation IDs found here
|
|
# https://techcommunity.microsoft.com/t5/windows-it-pro-blog/windows-server-2012-r2-extended-security-updates/ba-p/3976610
|
|
$Esu1Id = 'c0a2ea62-12ad-435b-ab4f-c9bfab48dbc4'
|
|
$Esu2Id = 'e3e2690b-931c-4c80-b1ff-dffba8a81988'
|
|
$Esu3Id = '55b1dd2d-2209-4ea0-a805-06298bad25b3'
|
|
|
|
$software = Get-WmiObject -Class SoftwareLicensingProduct
|
|
|
|
If ($Esu1Key) {
|
|
Write-Verbose -Message "Esu1Key found, checking LicenseStatus"
|
|
$EsuYear1 = $software | Where-Object { $_.Id -eq $Esu1Id }
|
|
If ($EsuYear1) {
|
|
If ($EsuYear1.LicenseStatus -eq '1') {
|
|
$Esu1Bool = $true
|
|
}
|
|
}
|
|
}
|
|
|
|
If ($Esu2Key) {
|
|
Write-Verbose -Message "Esu2Key found, checking LicenseStatus"
|
|
$EsuYear2 = $software | Where-Object { $_.Id -eq $Esu2Id }
|
|
If ($EsuYear2) {
|
|
If ($EsuYear2.LicenseStatus -eq '1') {
|
|
$Esu2Bool = $true
|
|
}
|
|
}
|
|
}
|
|
|
|
If ($Esu3Key) {
|
|
Write-Verbose -Message "Esu3Key found, checking LicenseStatus"
|
|
$EsuYear3 = $software | Where-Object { $_.Id -eq $Esu3Id }
|
|
If ($EsuYear3) {
|
|
If ($EsuYear3.LicenseStatus -eq '1') {
|
|
$Esu3Bool = $true
|
|
}
|
|
}
|
|
}
|
|
|
|
# Year 1 only
|
|
If ($Esu1Key -and $null -eq $Esu2Key -and $null -eq $Esu3Key) {
|
|
If ($Esu1Bool -eq $true) {
|
|
$compliant = $true
|
|
}
|
|
else {
|
|
$compliant = $false
|
|
}
|
|
}
|
|
|
|
# Year 1 & 2
|
|
If ($Esu1Key -and $Esu2Key -and $null -eq $Esu3Key) {
|
|
If ($Esu1Bool -eq $true -and $Esu2Bool -eq $true) {
|
|
$compliant = $true
|
|
}
|
|
else {
|
|
$compliant = $false
|
|
}
|
|
}
|
|
|
|
# Year 1 & 2 & 3
|
|
If ($Esu1Key -and $Esu2Key -and $Esu3Key ) {
|
|
If ($Esu1Bool -eq $true -and $Esu2Bool -eq $true -and $Esu3Bool -eq $true) {
|
|
$compliant = $true
|
|
}
|
|
else {
|
|
$compliant = $false
|
|
}
|
|
}
|
|
|
|
$compliant |