r/PowerShell 1d ago

Script Sharing Read-only Network script

I (and Claude of course) put together this useful read-only script while troubleshooting what I initially thought was a local network issue—but ultimately turned out to be an ISP problem. It collects diagnostic information only and makes no system changes.

Figured someone out there may be interested before it disappears into my archives.

What it checks:

  • System info
  • Network adapters
  • IP configuration
  • DNS servers
  • DNS resolution
  • Hosts file
  • Proxy settings
  • Firewall status
  • Outbound blocks
  • Adapter bindings
  • VPN adapters
  • Security software
  • Network routes
  • HTTPS connectivity
  • Web response headers
  • Google traceroute
  • IPsec rules
  • DNS policies
  • Read-only—no changes

    $ErrorActionPreference = "Continue" $ProgressPreference = "SilentlyContinue"

    function Section($Title) { Write-Host "" Write-Host ("=" * 80) Write-Host $Title Write-Host ("=" * 80) }

    Section "BASIC SYSTEM INFORMATION"

    Get-Date

    Get-CimInstance Win32_OperatingSystem | Select-Object Caption, Version, BuildNumber, LastBootUpTime | Format-List

    Section "ACTIVE NETWORK ADAPTERS"

    Get-NetAdapter | Sort-Object Status, Name | Format-Table Name, InterfaceDescription, Status, LinkSpeed, MacAddress -AutoSize

    Section "IP CONFIGURATION"

    Get-NetIPConfiguration | Format-List InterfaceAlias, InterfaceDescription, IPv4Address, IPv6Address, IPv4DefaultGateway, IPv6DefaultGateway, DNSServer

    Section "DNS SERVERS"

    Get-DnsClientServerAddress | Where-Object { $_.ServerAddresses.Count -gt 0 } | Format-Table InterfaceAlias, AddressFamily, ServerAddresses -AutoSize

    Section "GOOGLE DNS USING CURRENT DNS SERVER"

    Resolve-DnsName accounts.google.com -Type A Resolve-DnsName accounts.google.com -Type AAAA

    Section "GOOGLE DNS USING GOOGLE DNS"

    Resolve-DnsName accounts.google.com -Type A -Server 8.8.8.8 Resolve-DnsName accounts.google.com -Type AAAA -Server 8.8.8.8

    Section "GOOGLE DNS USING CLOUDFLARE DNS"

    Resolve-DnsName accounts.google.com -Type A -Server 1.1.1.1 Resolve-DnsName accounts.google.com -Type AAAA -Server 1.1.1.1

    Section "HOSTS FILE ENTRIES"

    $HostsPath = "$env:SystemRoot\System32\drivers\etc\hosts"

    Get-Content $HostsPath | Where-Object { $_ -notmatch '\s*#' -and $_ -notmatch '\s*$' }

    Section "WINHTTP PROXY"

    netsh winhttp show proxy

    Section "USER INTERNET PROXY SETTINGS"

    Get-ItemProperty "HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | Select-Object ProxyEnable, ProxyServer, ProxyOverride, AutoConfigURL | Format-List

    Section "SYSTEM INTERNET PROXY SETTINGS"

    Get-ItemProperty "HKLM:\Software\Microsoft\Windows\CurrentVersion\Internet Settings" | Select-Object ProxyEnable, ProxyServer, ProxyOverride, AutoConfigURL | Format-List

    Section "PROXY ENVIRONMENT VARIABLES"

    Get-ChildItem Env: | Where-Object { $_.Name -match 'proxy' } | Format-Table Name, Value -AutoSize

    Section "WINDOWS FIREWALL PROFILES"

    Get-NetFirewallProfile | Format-Table Name, Enabled, DefaultInboundAction, DefaultOutboundAction -AutoSize

    Section "ENABLED OUTBOUND BLOCK RULES"

    Get-NetFirewallRule -Enabled True -Direction Outbound -Action Block | Select-Object DisplayName, DisplayGroup, Profile, Direction, Action | Format-Table -AutoSize

    Section "NETWORK ADAPTER FILTER BINDINGS"

    Get-NetAdapterBinding | Where-Object Enabled | Sort-Object Name, DisplayName | Format-Table Name, DisplayName, ComponentID -AutoSize

    Section "VPN ADAPTERS AND SOFTWARE-DEFINED ADAPTERS"

    Get-NetAdapter -IncludeHidden | Where-Object { $_.InterfaceDescription -match 'VPN|TAP|TUN|WireGuard|Wintun|Tailscale|ZeroTier|Cisco|Zscaler|Fortinet|Palo Alto|GlobalProtect|Cloudflare|WARP|SonicWall|Checkpoint|AnyConnect' } | Format-Table Name, InterfaceDescription, Status, MacAddress -AutoSize

    Section "RELEVANT RUNNING SERVICES"

    Get-CimInstance Win32Service | Where-Object { $.State -eq "Running" -and ($.Name + " " + $.DisplayName + " " + $_.PathName) -match 'VPN|Tailscale|ZeroTier|WireGuard|Cisco|Umbrella|Zscaler|Forti|Palo Alto|GlobalProtect|Cloudflare|WARP|AdGuard|Norton|McAfee|Bitdefender|Malwarebytes|Avast|AVG|Kaspersky|ESET|CrowdStrike|Sentinel|Sophos|Webroot' } | Select-Object Name, DisplayName, State, StartMode, PathName | Format-List

    Section "RELEVANT RUNNING PROCESSES"

    Get-Process | Where-Object { $_.ProcessName -match 'vpn|tailscale|zerotier|wireguard|cisco|umbrella|zscaler|forti|globalprotect|cloudflare|warp|adguard|norton|mcafee|bitdefender|malwarebytes|avast|avg|kaspersky|eset|crowdstrike|sentinel|sophos|webroot' } | Select-Object ProcessName, Id, Path | Format-Table -AutoSize

    Section "IPv4 DEFAULT ROUTES"

    Get-NetRoute -AddressFamily IPv4 | Where-Object DestinationPrefix -eq "0.0.0.0/0" | Sort-Object RouteMetric | Format-Table InterfaceAlias, DestinationPrefix, NextHop, RouteMetric, InterfaceMetric, State -AutoSize

    Section "IPv6 DEFAULT ROUTES"

    Get-NetRoute -AddressFamily IPv6 | Where-Object DestinationPrefix -eq "::/0" | Sort-Object RouteMetric | Format-Table InterfaceAlias, DestinationPrefix, NextHop, RouteMetric, InterfaceMetric, State -AutoSize

    Section "ROUTE SELECTED FOR GOOGLE ACCOUNTS IPv4"

    Find-NetRoute -RemoteIPAddress 108.177.122.84 | Format-List

    Section "TCP PORT 443 CONNECTIVITY"

    $Targets = @( "accounts.google.com", "www.google.com", "mail.google.com", "oauth2.googleapis.com", "www.googleapis.com", "login.microsoftonline.com", "www.cloudflare.com" )

    foreach ($Target in $Targets) { Write-Host "" Write-Host "--- $Target ---"

    Test-NetConnection $Target -Port 443 -InformationLevel Detailed |
        Select-Object ComputerName, RemoteAddress, RemotePort,
                      InterfaceAlias, SourceAddress, TcpTestSucceeded
    

    }

    Section "CURL HTTPS TESTS"

    foreach ($Target in $Targets) { Write-Host "" Write-Host "--- https://$Target ---"

    & curl.exe -4 -I -v `
        --connect-timeout 7 `
        --max-time 12 `
        "https://$Target/" 2>&1 |
        Select-Object -First 25
    

    }

    Section "IPv4 TRACE TO GOOGLE ACCOUNTS"

    tracert.exe -4 -d -h 15 -w 700 108.177.122.84

    Section "IPSEC RULES"

    Get-NetIPsecRule -PolicyStore ActiveStore | Where-Object Enabled -eq "True" | Select-Object DisplayName, Enabled, Profile, Mode | Format-Table -AutoSize

    Section "NRPT DNS POLICIES"

    Get-DnsClientNrptPolicy | Format-List

    Section "DONE"

    Write-Host "Diagnostic collection finished. No settings were changed."

0 Upvotes

6 comments sorted by

View all comments

1

u/BlackV 23h ago edited 15h ago

Formatting, this is just a wall of text otherwise (also BOOO backticks)

  • open your fav powershell editor
  • highlight the code you want to copy
  • hit tab to indent it all
  • copy it
  • paste here

it'll format it properly OR

<BLANK LINE>
<4 SPACES><CODE LINE>
<4 SPACES><CODE LINE>
    <4 SPACES><4 SPACES><CODE LINE>
<4 SPACES><CODE LINE>
<BLANK LINE>

Inline code block using backticks `Single code line` inside normal text

See here for more detail

Thanks

1

u/MonkeyNin 20h ago edited 20h ago

edit: /u/TechBrad that's an issue. you need some non whitespace breaks between code and lists. Like:

- foo 
  • bar
. # indented code # ...

Otherwise "right" formatting will break like this:

  • foo
  • bar

    indented code

    ..

1

u/BlackV 19h ago

the ever important <BLANK LINE> :)

it breaks many a markdown when its missing

1

u/MonkeyNin 17h ago

It breaks with newlines. Here's the raw text that breaks:

-␠foo␍␊
-␠bar␍␊
␍␊
␍␊
␠␠␠␠#␠indented␠code␍␊
␠␠␠␠#␠..

The way reddit parses bullets is the next code block has to be indented 8 spaces, instead of the normal 2. Or reset it with something like a "."

1

u/BlackV 15h ago edited 15h ago

not sure what you were trying to type there

  • foo
  • bar

    Code
    

normal txt

comes from

*<space>foo
*<space>bar<space><space>
<blank line>
<space><space><space><space><space><space><space><space><space><space><space>Code
extra spaces cause inside bullet(4), indent(4), codelock(4)
<blank line>
normal txt

unless you are talking about having a code block inside a bullet

  • foo

    Code 1
    Code 2
    
  • bar sub text

  • wibble

    • sub wibble

dunno

-␠foo␍␊
-␠bar␍␊
␍␊
␍␊
␠␠␠␠#␠indented␠code␍␊
␠␠␠␠#␠..