PowerShell Get-BrowseMaster Function

PowerShell PowerShell Get-BrowseMasterFunction to Find Browse Master

Knowledge of the Windows Browse Master can help troubleshoot latency and related connection problems on a local network.  Here is how to create a useful PowerShell function called Get-BrowseMaster.

Project Steps To Discover the Browse Master


NBTStat -a MachineName

Following the demise of the resource kit's gadget called Browmon, we need to trawl through the output of the built-in Windows NBTStat utility to discover the browse master computer on your network.

NBTSTAT -a $Env:ComputerName

Note 1: $Env:ComputerName retrieves the local host's NetBios name.

NetBIOS Remote Machine Name Table

Name Type Status
WIN7 <00> UNIQUE Registered
HOMEGROUP <00> GROUP Registered
WIN7 <20> UNIQUE Registered
..__MSBROWSE__.<01> GROUP Registered

MAC Address = 20-CF-30-3A-B5-63

Key point: Only the browse master has this specific NetBIOS record:
..__MSBROWSE__.<01> GROUP Registered.

Windows PowerShell Logic

In any scripting language I am very fond putting the 'If' logic to good use.  The key point of this command is that when the output of NBTStat contains MSBrowse, then we have found the local network's browse master.  One feature of this function is the way it combines built-in Microsoft Windows utilities, with PowerShell commands.

Check if the local machine is the browse master:

# PowerShell checks if local machine is the Windows Browse Master
$Discovery = NBTStat -a $Env:ComputerName |
Out-String -Stream | Select-String "MSBrowse"
If($Discovery -match "MSBrowse") {
"$Env:ComputerName is the Browse master"

Note 2: Out-String -Stream and Select-String are just my tactics for obtaining a string, which I then match with MSBrowse.

Problem: What if the local machine is not the browse master?
Solution: Get a list of all the machines on the network, then test each one with NBTStat to see if it's the browse master.

Collecting Computer Names on the Local Network

Microsoft's simple 'Net View' command will list all the machines on the local network.  The only problem is how to strip out the extra backslashes and description, and thus leave the bare computer names.  The answer is to use PowerShell's Switch -RegEx (Regular Expression).

Switch -RegEx (NET.EXE VIEW) {
"^\\\\(?<Name>\S+)\s+" {$matches.Name}

PowerShell Function Get-BrowseMaster

At the heart of the function below is the Process section; you could say that the rest of the script is just a wrapper so that you can execute the PowerShell and Windows instructions with the one command I call: Get-BrowseMaster.  The other benefit of a function is that you can introduce parameters.

Function Global:Get-BrowseMaster {
[String]$LocalMachine ="$Env:COMPUTERNAME",
$x = 0
### Check if the local machine is the Browse Master ####
$Discovery = NBTStat -a $LocalMachine | Out-String -Stream | Select-String "MSBrowse"
If($Discovery -match "MSBrowse") {
Write-Host "$LocalMachine is the Browse master" -BackgroundColor Magenta ;$x =1
#### Logic to find Browse Master on the network ####
If($x -ne 1 -or $All) {
$NetworkComputer =switch -RegEx (NET.EXE VIEW) {
"^\\\\(?<Name>\S+)\s+" {$matches.Name}
($LocalMachine in $NetworkComputer) {
$Discovery = NBTStat -a $LocalMachine | Out-String -Stream | Select-String "MSBrowse"
If($Discovery -match "MSBrowse") {
Write-Host "$LocalMachine is the Browse Master" -BackgroundColor Magenta
Else  {
"$LocalMachine is an imposter"
          } # End of Foreach
      } # End of If
   } # End of Process
} # End of Function Get-BrowseMaster


Note 3: Do remember to execute the function by typing Get-BrowseMaster.

Note 4: To see all the machines on the local network type: Get-BrowseMaster -All

Note 5: If you suspect another machine of being the Windows browse master, then save time, and use the -LocalMachine parameter.

Guy Recommends:  A Free Trial of the Network Performance Monitor (NPM)Review of Orion NPM v11.5 v11.5

SolarWinds’ Network Performance Monitor will help you discover what’s happening on your network.  This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

What I like best is the way NPM suggests solutions to network problems.  Its also has the ability to monitor the health of individual VMware virtual machines.  If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.

Download a free trial of Solarwinds’ Network Performance Monitor

Other Ideas to Find the Browse Master

Please regard the above function as a starting point.  This is a relatively easy topic to understand, and fun to modify the code to suit your needs.

Before I discovered how to parse Net View, I toyed with the idea of listing all the local machine in an array.  The short-coming of this tactic is that we would have to know the local machine names in advance.

[Array]$NetworkComputer = @("Dozy","Nobody","Win8,","Win7")

Another idea I had was to discover which machines on the network were members of the HomeGroup.

Returning to my Get-BrowseMaster function, it could be improved by having these three sections in the header: .Synopsis, .Description and .Examples.

Next Step: Changing the Browse Master

Microsoft designed the browse master for networks without a DNS server.  The idea is that one machine in the homegroup (or workgroup) keeps a list of all the computers on the local network, and then the other machines contact that browse master when they need to find resources on a remote machine.  For example a user types: \\OtherComputer\Photos.

The most common browse master configuration is that all computer have the default 'Auto' as their MaintainServerList value.  This means that any Windows computer can potentially be the Browse Master, although it's usually the first one to boot that assumes this role.  If a browse master shuts down then there is an election for a new Browse Master, (which are hidden from the users), and the winner is usually the Windows 8 or Windows 7 machine that has been running the longest.

Now it's possible to rig the browse master election by changing a registry setting called MaintainServerList from 'Auto' to 'Yes', or 'No'.

See more PowerShell's controlling MaintainServerList »

Net View and NBTStat

In this instance I did not need to disconnect the firewall to get these commands to work.

Engineer's Toolset v10Guy Recommends: SolarWinds Engineer’s Toolset v10

This Engineer’s Toolset v10 provides a comprehensive console of 50 utilities for troubleshooting computer problems.  Guy says it helps me monitor what’s occurring on the network, and each tool teaches me more about how the underlying system operates.

There are so many good gadgets; it’s like having free rein of a sweetshop.  Thankfully the utilities are displayed logically: monitoring, network discovery, diagnostic, and Cisco tools.  Try the SolarWinds Engineer’s Toolset now!

Download your fully functional trial copy of the Engineer’s Toolset v10

Create Additional PowerShell Functions 

Almost every time I create a PowerShell script I wrap it into a function.  At first this is a daunting process, but if you break it down into stages, then it's actually not difficult.  As with other learning processes, we get better by doing.

See more PowerShell's controlling MaintainServerList »

Summary of Get-Browser Function

I have laid-out the stages for creating a function called Get-BrowseMaster.  The main element is the Windows command NBTStat, the rest of the script deals with extracting the computer names using PowerShell commands, and the logic of interpreting which is the browse master.

If you like this page then please share it with your friends


See More PowerShell Function Parameters

Scripting PowerShell Function   • PowerShell Function Parameter  • Free Import User CSVDE Tool

PowerShell Function Get-ServiceStatus   • PowerShell Get-BrowseMaster   • PowerShell Send-Email

Create PowerShell Function   • PowerShell Function Get-WmiClass  • PowerShell Function Get-Uptime

Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.