Print Nightmare Fix

Recently most Administrators have frantically been patching and remediating a known Print Spooler Vulnerability.

Function Test-RegistryValue($regkey, $name) {
$exists = Get-ItemProperty -Path “$regkey” -Name “$name” -ErrorAction SilentlyContinue
If (($exists -ne $null) -and ($exists.Length -ne 0)) {
Return $true
}
Return $false
}

$i=0
$regkey = “HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint”

$name = “NoWarningNoElevationOnInstall”
if(Test-RegistryValue -regkey $regkey -name $name){
$value = (Get-ItemProperty -Path $regkey -Name $name | Select-Object $name).$name
if($value -ne 0){$i++}
}

$name = “UpdatePromptSettings”
if(Test-RegistryValue -regkey $regkey -name $name){
$value = (Get-ItemProperty -Path $regkey -Name $name | Select-Object $name).$name
if($value -ne 0){$i++}
}

$name = “RestrictDriverInstallationToAdministrators”
if(Test-RegistryValue -regkey $regkey -name $name){
$value = (Get-ItemProperty -Path $regkey -Name $name | Select-Object $name).$name
if($value -ne 1){$i++}
}else{
if(Test-Path $regkey){$i++}
}

if($i -eq 0){Write-Host “Installed”}

Function Test-RegistryValue($regkey, $name) {
$exists = Get-ItemProperty -Path “$regkey” -Name “$name” -ErrorAction SilentlyContinue
If (($exists -ne $null) -and ($exists.Length -ne 0)) {
Return $true
}
Return $false
}

$regkey = “HKLM:\SOFTWARE\Policies\Microsoft\Windows NT\Printers\PointAndPrint”

$name = “NoWarningNoElevationOnInstall”
if(Test-RegistryValue -regkey $regkey -name $name){
$value = (Get-ItemProperty -Path $regkey -Name $name | Select-Object $name).$name
if($value -ne 0){
New-ItemProperty -Path $regkey -Name $name -Value 0 -Force
}
}

$name = “UpdatePromptSettings”
if(Test-RegistryValue -regkey $regkey -name $name){
$value = (Get-ItemProperty -Path $regkey -Name $name | Select-Object $name).$name
if($value -ne 0){
New-ItemProperty -Path $regkey -Name $name -Value 0 -Force
}
}

$name = “RestrictDriverInstallationToAdministrators”
if(Test-RegistryValue -regkey $regkey -name $name){
$value = (Get-ItemProperty -Path $regkey -Name $name | Select-Object $name).$name
if($value -ne 1){
New-ItemProperty -Path $regkey -Name $name -Value 1 -Force
}
}else{
if(Test-Path $regkey){
New-ItemProperty -Path $regkey -Name $name -Value 1 -Force
}
}

WordPress Appliance - Powered by TurnKey Linux