Get-NetworkProfileReport.ps1
|
<#PSScriptInfo
.VERSION 1.0.0 .GUID 8c59a0ce-a761-4520-8c4f-aa83002b5119 .AUTHOR Coinetic AI Security - https://coinetic.io .COMPANYNAME Coinetic AI Security .COPYRIGHT (c) 2026 Coinetic AI Security - https://coinetic.io. MIT licence. .TAGS Coinetic Windows WindowsServer NetworkProfile NetworkCategory Public Private Domain NLA Firewall .LICENSEURI https://github.com/Coinetic-AI-Security/windows-network-profile-fix/blob/main/LICENSE .PROJECTURI https://github.com/Coinetic-AI-Security/windows-network-profile-fix .ICONURI https://coinetic.io/logo-192.png .RELEASENOTES 1.0.0: every network connection with its profile (Domain / Private / Public), gateway, DNS servers, DNS suffix and the likely reason it is Public. #> <# .SYNOPSIS Shows the network profile (Domain, Private or Public) of every network connection - and why Windows may have made it Public. Free tool by Coinetic AI Security - https://coinetic.io .DESCRIPTION Windows gives every network connection a network profile (also called network location or network category): DomainAuthenticated, Private or Public. Each profile has its own Windows Firewall rules, so a connection that is Public when it should be Domain or Private silently switches off rules for Remote Desktop, file sharing or monitoring. For every connection this report shows: - the network name and its category (DomainAuthenticated / Private / Public) - IPv4 / IPv6 connectivity as Windows sees it - the default gateway (no gateway = "Unidentified network" = Public by default) - the DNS servers and the connection-specific DNS suffix - whether the Windows Firewall profile for that category is on - hints why the category may be wrong, and which script fixes it Built-in commands only: Get-NetConnectionProfile, Get-NetIPConfiguration, Get-DnsClient, Get-DnsClientServerAddress, Get-NetFirewallProfile, Get-CimInstance Win32_ComputerSystem. No translated text is parsed, so it works on any Windows language. The script CHANGES NOTHING. .PARAMETER Csv Also write the report to this CSV file. .PARAMETER Quiet Do not print the report; only return the objects. .EXAMPLE .\Get-NetworkProfileReport.ps1 .EXAMPLE .\Get-NetworkProfileReport.ps1 -Csv "$env:USERPROFILE\Desktop\network-profiles.csv" .EXAMPLE Invoke-Command -ComputerName SRV1, SRV2 -FilePath .\Get-NetworkProfileReport.ps1 .LINK https://coinetic.io .LINK https://coinetic.io/network-profile-public #> [CmdletBinding()] param([string]$Csv, [switch]$Quiet) Set-StrictMode -Version 2.0 $ErrorActionPreference = 'Stop' if (-not (Get-Command Get-NetConnectionProfile -ErrorAction SilentlyContinue)) { throw 'Get-NetConnectionProfile is missing. It is built into Windows 8 / Windows Server 2012 and later.' } # Well-known public DNS resolvers. A domain member that uses one of them may not find its domain controller. $publicResolvers = @('8.8.8.8', '8.8.4.4', '1.1.1.1', '1.0.0.1', '9.9.9.9', '149.112.112.112', '208.67.222.222', '208.67.220.220', '2001:4860:4860::8888', '2001:4860:4860::8844', '2606:4700:4700::1111', '2606:4700:4700::1001') function Get-Prop($Object, [string]$Name) { if ($null -ne $Object -and $Object.PSObject.Properties[$Name]) { return $Object.$Name } return $null } $cs = Get-CimInstance -ClassName Win32_ComputerSystem $partOfDomain = [bool]$cs.PartOfDomain $domain = if ($partOfDomain) { [string]$cs.Domain } else { '' } $fwProfiles = @{} foreach ($fp in @(Get-NetFirewallProfile -PolicyStore ActiveStore -ErrorAction SilentlyContinue)) { $fwProfiles[[string]$fp.Name] = $fp } $rows = New-Object System.Collections.Generic.List[object] foreach ($p in @(Get-NetConnectionProfile -ErrorAction SilentlyContinue)) { $ifIndex = [int]$p.InterfaceIndex $category = [string]$p.NetworkCategory $gateways = @() $dnsServers = @() $suffix = '' try { $ipc = Get-NetIPConfiguration -InterfaceIndex $ifIndex -ErrorAction Stop foreach ($g in @((Get-Prop $ipc 'IPv4DefaultGateway')) + @((Get-Prop $ipc 'IPv6DefaultGateway'))) { if ($g -and $g.NextHop) { $gateways += [string]$g.NextHop } } } catch { } try { $dnsServers = @(Get-DnsClientServerAddress -InterfaceIndex $ifIndex -ErrorAction Stop | ForEach-Object { $_.ServerAddresses } | Where-Object { $_ }) } catch { } try { $suffix = [string](Get-DnsClient -InterfaceIndex $ifIndex -ErrorAction Stop).ConnectionSpecificSuffix } catch { } # Firewall profile that applies to this category (Domain / Private / Public) $fwName = switch ($category) { 'DomainAuthenticated' { 'Domain' } 'Private' { 'Private' } default { 'Public' } } $fwOn = '' if ($fwProfiles.ContainsKey($fwName)) { $fwOn = [string]$fwProfiles[$fwName].Enabled } $hints = New-Object System.Collections.Generic.List[string] $publicDns = @($dnsServers | Where-Object { $publicResolvers -contains $_ }) $looksLikeDomainLan = $partOfDomain -and $suffix -and $domain -and ($suffix -ieq $domain -or $suffix.EndsWith('.' + $domain, [StringComparison]::OrdinalIgnoreCase)) if ($category -eq 'DomainAuthenticated') { $hints.Add('OK: Windows reached a domain controller over this connection.') } if ($gateways.Count -eq 0 -and $category -ne 'DomainAuthenticated') { $hints.Add('No default gateway: Windows cannot identify this network ("Unidentified network") and treats it as Public unless the Unidentified Networks policy says otherwise.') } if ($partOfDomain -and $category -ne 'DomainAuthenticated' -and ($looksLikeDomainLan -or $gateways.Count -gt 0)) { $hints.Add("Domain member, but this connection is $category. If this is the domain network, domain detection failed (domain controller or DNS not reachable when the network came up): run Repair-DomainNetworkProfile.ps1. Do not set it to Private instead.") } if ($partOfDomain -and $publicDns.Count -gt 0) { $hints.Add("Uses public DNS server(s) $($publicDns -join ', '): a domain member should use only the domain's DNS servers, or it may not find a domain controller.") } if (-not $partOfDomain -and $category -eq 'Public') { $hints.Add('New networks start as Public. If you trust this network (home or office LAN), set it to Private: Set-NetworkProfilePrivate.ps1. Keep hotel, cafe and other shared Wi-Fi on Public.') } if ($fwOn -eq 'False') { $hints.Add("The Windows Firewall profile $fwName is switched OFF.") } $rows.Add([pscustomobject]@{ InterfaceAlias = [string]$p.InterfaceAlias InterfaceIndex = $ifIndex NetworkName = [string]$p.Name Category = $category IPv4 = [string]$p.IPv4Connectivity IPv6 = [string]$p.IPv6Connectivity Gateway = $gateways -join ', ' DnsServers = $dnsServers -join ', ' DnsSuffix = $suffix FirewallProfile = $fwName FirewallOn = $fwOn Hints = $hints -join ' | ' }) } $list = @($rows | Sort-Object InterfaceAlias) if ($Csv) { $list | Export-Csv -Path $Csv -NoTypeInformation -Encoding UTF8 } if ($Quiet) { return $list } if ($partOfDomain) { Write-Host "This computer is a member of the domain $domain." } else { Write-Host 'This computer is not a domain member (workgroup): only Private or Public apply.' } Write-Host '' foreach ($r in $list) { Write-Host ("{0} -> {1}" -f $r.InterfaceAlias, $r.Category) -ForegroundColor $(if ($r.Category -eq 'Public') { 'Yellow' } else { 'Green' }) $r | Format-List NetworkName, IPv4, IPv6, Gateway, DnsServers, DnsSuffix, FirewallProfile, FirewallOn | Out-Host foreach ($h in ($r.Hints -split ' \| ')) { if ($h) { Write-Host " - $h" } } Write-Host '' } if ($list.Count -eq 0) { Write-Host 'No connected network with a profile was found.' } if ($Csv) { Write-Host "Report written to $Csv" } Write-Host 'Guide: https://coinetic.io/network-profile-public' Write-Host 'Free tool by Coinetic AI Security - https://coinetic.io' |