Skip to content

Instantly share code, notes, and snippets.

@SweetAsNZ
Created February 19, 2026 02:32
Show Gist options
  • Select an option

  • Save SweetAsNZ/34e5fccaf60321e8256f9244224922b7 to your computer and use it in GitHub Desktop.

Select an option

Save SweetAsNZ/34e5fccaf60321e8256f9244224922b7 to your computer and use it in GitHub Desktop.
Get Edge's Proxy Server and if it uses a .PAC file parse that for the server names and ports
function Get-EdgeProxy {
<#
.SYNOPSIS
Gets Microsoft Edge proxy settings from the registry.
.DESCRIPTION
Returns the Microsoft Edge proxy settings by reading the relevant registry keys. This includes whether the proxy is enabled, the proxy server address, any proxy override settings, and the auto-configuration URL if set.
.EXAMPLE
Get-EdgeProxy
.NOTES
#>
[CmdletBinding()]
param (
[switch]$ParsePAC = $true
)
# System proxy (WinINET - what Edge uses by default)
$proxy = Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings"
[PSCustomObject]@{
ProxyEnable = $proxy.ProxyEnable
ProxyServer = $proxy.ProxyServer
ProxyOverride = $proxy.ProxyOverride
AutoConfigURL = $proxy.AutoConfigURL
}
# Parse PAC for Proxy Entries
if($ParsePAC){
if($Proxy.AutoConfigURL -like "*.pac"){
Write-Host -f Green "Parsing PAC file for proxy entries..."
$pac = Invoke-WebRequest $Proxy.AutoConfigURL -UseBasicParsing
$text = [System.Text.Encoding]::UTF8.GetString($pac.Content)
$RawProxies = $text -split "`n" | Select-String -Pattern "PROXY\s" | Select-String -Simplematch '.' | Sort-Object | Get-Unique
$Proxies = $RawProxies | Sort-Object
# Split servers and ports from the PROXY lines
$proxyEntries = $Proxies | ForEach-Object {
$line = $_.Line.Trim()
if ($line -match "PROXY\s+(\S+)") {
$proxyServer = $matches[1]
return $proxyServer
}
} | Where-Object { $_ -ne $null }
return $proxyEntries | Sort-Object | Get-Unique
}
else{
Write-Host -f Yellow "No PAC file configured, skipping proxy entry parsing."
}
}
else{
Write-Host -f Yellow "PAC file parsing disabled, skipping proxy entry parsing."
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment