Manipulate the Browse Master with PowerShell
Our mission is to control the Computer Browser Service, we will do this by changing a registry value called MaintainServerList.
The benefit is to control which machine on the network keeps a map of all the computers on the network.
Our main method uses PowerShell rather than regedit to change the value from 'Auto' to 'Yes'.
Topics for Controlling the Browse Master
- PowerShell Finds MaintainServerList in the Registry
- Options for MaintainServerList
- Changing the Browse Master with MaintainServerList
- PowerShell Function Get-BrowseMaster
♣
PowerShell Finds MaintainServerList in the Registry
The first point is that PowerShell sees the registry as a drive, consequently you can connect to HKLM:\ just as you would to C:\ drive. Do remember that colon:, and as expected the forward slash connects to the root of the HKEY_LOCAL_MACHINE hive.
Secondly, we need to find MaintainServerList, to do this we drill down under the CurrentControlSet, Services, Browser registry hive.
Thirdly, the default value for MaintainServerList is 'Auto', meaning the computer takes part in Windows browse master elections. Below is my PowerShell script to reveal the value of MaintainServerList in the registry. In a later script we will change 'Auto' to 'Yes'.
# PowerShell script to check MaintainServerList
Clear-Host
$Reg = "HKLM:\SYSTEM\CurrentControlSet\services\Browser\Parameters"
$BrowseMaster = Get-ItemProperty -path $Reg -Name MaintainServerList
"MaintainServerList: " + $BrowseMaster.MaintainServerList
Note 1: The key PowerShell command here is Get-ItemProperty, later we will use the 'Set' verb.
Options for MaintainServerList
Remember that browse lists are only important on small networks without their own DNS server. The concept is that one machine keeps the list of all the computers on the network; the other machines then contact that browse master when a user wants to connect to a network share.
The most common scenario is that all computer have MaintainServerList set to the default 'Auto'. This means that any Windows computer can potentially be the Browse Master, although in practice it's usually the first one to boot. If a browse master shuts down then there is a Browse Master election, which is hidden from the users, and the winner is usually the Windows 8 or Windows 7 machine that has been running the longest.
The point of this page is to show that it's possible to rig the browse master election by changing the value of MaintainServerList to 'Yes', or 'No'.
Changing the Browse Master with MaintainServerList
Scenario:
- Windows 7 Machine 'Red' has been up the longest, and is the Browse Master
- Windows 8 Machine 'Green'
- Windows 7 Machine 'White'
Experiment:
Change MaintainServerList on 'White' from 'Auto' to 'Yes'
Result:
- Windows 7 Machine 'Red' MaintainServerList 'Auto'
- Windows 8 Machine 'Green' MaintainServerList 'Auto'
- Windows 7 Machine 'White' MaintainServerList 'Yes' becomes Browse Master
Note 2: This only works after you restart the Computer Browser Service on both 'White' and 'Red', alternatively you could restart the machines.
# Run this PowerShell script on your 'White' machine
Clear-Host
$Reg = "HKLM:\SYSTEM\CurrentControlSet\services\Browser\Parameters"
Set-ItemProperty -path $Reg -Name MaintainServerList -Value "Yes"
Restart-Service 'Computer Browser'
Beware: Always take care with scripts that use PowerShell's 'Set' verb.
Note 3: Remember to run Restart-Service 'Computer Browser' on the existing Browse Master (Red). This saves a reboot.
Guy Recommends: A Free Trial of the Network Performance Monitor (NPM) 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
Using Regedit to Change MaintainServerList
I mention regedit because when ever there is a GUI equivalent of my PowerShell script, I like to study the settings in parallel, it helps give me a stereoscopic vision of the project. Values I see in the GUI help with my scripts, and vica versa.
Note 4: Valid options for MaintainServerList are 'Auto', 'No' and 'Yes'; my point is that values of zero or 1 don't work.
Note 5: Do make sure you are working with the CurrentControlSet, and not 001 or 002.
Note 6: If you set the value to 'No', then you get an error when you try to restart the computer browser service on that machine.
Research More PowerShell Cmdlets
# Research more PowerShell registry cmdlets
Get-Command -Noun ItemProperty
Expected Results
Clear-ItemProperty
Copy-ItemProperty
Get-ItemProperty
Move-ItemProperty
New-ItemProperty
Remove-ItemProperty
Rename-ItemProperty
Set-ItemProperty
See more examples of PowerShell ItemProperty »
Summary of PowerShell Changes MaintainServerList
The point of this page is to control the Computer Browser Service by changing the registry value MaintainServerList. For this task we used PowerShell rather than regedit.
If you like this page then please share it with your friends
See more Microsoft PowerShell Examples of Real Life Tasks
• PowerShell Real-life Examples • Test-Connection • Invoke-Expression • Invoke-Command
• Com • Shell Application • Measure-Object • PowerShell Registry • Compare-Object Registry
• PowerShell and Exchange • PowerShell and SQL • Restore-Computer • Engineers Toolset
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.