This script will check for the HKLM and HKCU NoLockScreen Registry Key as well as automatically change it from 0 to 1 if found.

If the key is not found, or it is already set to 0, this information will also be displayed.

To run, Copy and Paste and run in an Admin PowerShell Prompt or run from PSISE after setting Execution-Policy Unrestricted

 

PowerShell
Edit|Remove
###############################  
### NoLockScreen Check 0.91 ###  
###############################  
CLS  
Write-Host "`n### NoLockScreen Check 0.91###`n`n"  
 
## List of registry locations to check: 
$paths = @("HKLM:\SOFTWARE\Policies\Microsoft\Windows\Personalization\", 
            "HKCU:\SOFTWARE\Policies\Microsoft\Windows\Personalization\") 
## List of keys to check: 
$values = @("NoLockScreen", 
            "NoChangingLockScreen") 
 
## Checking for Locations and Keys 
For($i=0;$i -lt $paths.Length; $i++) 
{ 
    For($n=0;$n -lt $values.Length; $n++) 
    { 
        If(((Get-ItemProperty -Path $paths[$i-EA SilentlyContinue).($values[$n])) -eq 1)  
            {Write-Host $paths[$i],$values[$n" - Value of 1 Found: Changing to 0 ...`n" -Separator ""                 
                ## If NoLockScreen = 1 Change to 0  
                Set-ItemProperty -Path $paths[$i-Name $values[$n-Value 0}  
                    ## If NoLockScreen = 0 - No Change  
                    elseif(((Get-ItemProperty -Path $paths[$i-EA SilentlyContinue).($values[$n])) -eq 0)  
                        {Write-Host $paths[$i],$values[$n], " - Value already set to 0.`n" -Separator ""}  
                            else{Write-Host $paths[$i],$values[$n" - Does not seem to exist.`n" -Separator ""} 
    } 
}  
  
Write-Host "`n`nFull listing of all values (blank if none) ...`n"   
 
foreach($path in $paths){Get-Item -Path $paths -EA SilentlyContinue} 
  
### EOF JohnEM 11/2019 ###