Try { $Key = Get-Item -LiteralPath HKCU:\"Software\Microsoft\Windows\CurrentVersion\Internet Settings" If(($Key.GetValue("AutoConfigURL" ,$null) -ne $null) -and (($Key.GetValue("AutoConfigURL" ,$null)).Length -ne 0)) { Write-Host "AutoConfig URL is "$Key.GetValue("AutoConfigURL" ,$null) } If(($Key.GetValue("AutoConfigProxy" ,$null) -ne $null) -and (($Key.GetValue("AutoConfigProxy" ,$null)).Length -ne 0)) { Write-Host "AutoConfig Proxy is "$Key.GetValue("AutoConfigProxy" ,$null)} Switch ($Key.GetValue("ProxyEnable" ,$null)) { 0 {Write-Host "Proxy is Disabled" } 1 {Write-Host "Proxy is Enabled" } } Switch ($Key.GetValue("EnableAutodial" ,$null)) { 0 {Write-Host "Auto dial is Disabled" } 1 {Write-Host "Auto dial is Enabled" } } Write-Host "Script Check Passed" Exit 0 } Catch { Write-Host("Script Check Failed") Exit 1001 }