Failover Clustering and Network Load Balancing Team Blog
Hi NLB Fans,
NLB provides users with various methods to manage clusters. In Windows Server 2008, there are 3 ways to manage an NLB cluster:
1. Network Load balancing Manager GUI (nlbmgr.exe)
2. NLB command line tool (Nlb.exe)
3. NLB WMI Provider (root\MicrosoftNLB namespace)
In Windows Server 2008 R2, the NLB team has introduced a PowerShell interface for configuring, managing and debugging NLB. This awesome new feature makes it very easy to administer systems in an automated way.
In this blog post we will explore NLB's support for PowerShell. We will elaborate on the original post PowerShell for NLB, providing more details on naming mechanism, samples and CMDlet discovery.
This blog post contains the following sections:
· PowerShell Naming convention
· Exploring NLB CMDlets
o Using Get-Command
o Using command Auto-completion
o Using Argument auto completion
o Getting examples to use
Future blog posts in this series will discuss:
· NLB common scenarios
· Basics of Debugging NLB with PowerShell
NLB PowerShell follows the PowerShell CMDlet guidelines in naming and execution of the NLB CMDlets. Here we will explore the general naming conventions that will make it easy to further understand and explore NLB CMDlets.
A CMDlet is made up of two parts a Noun and a Verb. These two parts of speech are combined together with a hyphen in between. A NLB example would be:
PS > Get-NlbCluster
The ‘Get’ example above is split into 2 parts, the verb (Get) and the noun (NlbCluster), and these 2 words are separated by a hyphen. As rule of thumb, the verb defines the action to be performed on the noun. In the above example, we want to "Get" all instances of "NlbCluster".
To view all the NLB CMDlets, run PS > Get-Command –module NetworkLoadBalancingClusters
A list of all the NLB supported verbs can be seen below:
A list of all the NLB supported nouns can be seen below:
PowerShell makes it quite easy to use CMDlets, even if you have no prior knowledge of the NLB CMDlets. PowerShell provides two main features that help with exploring/learning CMDlets.
You can use Get-Command to explore existing CMDlets that are available. This CMDlet, in conjunction with the knowledge of Verb-Noun pairing is a powerful way to getting to the CMDlet of interest.
> Get-command -module NetworkLoadBalancingClusters [-Noun | -Verb <String>]
> Get-command <CommandFilter> -commandtype <commandtype>
Let say we want to delete a node from the current cluster. We know our end goal, but don’t know how to achieve it via PowerShell. Using the above syntax we can try to reach our goal. So the action we want to perform is "delete", and the noun that we want to act on is "NLB Cluster Node".
First we try to find all commands that start with "delete" verb and are of type CMDlet, by running > Get-Command delete-* -commandType cmdlet, but do not find any results.
Instead of "delete" let’s try “Remove". Below we see that we found the CMDlet we are looking for.
We could have approached this in a different way. We could have searched for the noun "Node" and filtered further on the exact verb.
As we can see with the above examples, we can intuitively guess the Verb-Noun pair for the NLB operation we want to perform, and use the Get-Command CMDlet to get the exact CMDlet.
The list below shows the usage of Get-Command to list out all the supported NLB CMDlets:
Another way to find out what CMDlets exist is to use the command auto-completion key <TAB>.
PowerShell provides a feature where the arguments of a CMDlet autocomplete.
1. Open PowerShell window with the NLB modules loaded.
2. Type Add-NLBCluster<Tab>
This will automatically complete the above CMDlet, and display "Add-NLBClusterNode" on the screen.
This is another handy way to see what all CMDlets are supported. Another example would be:
Start-NLB<TAB> would display Start-NLBCluster
Hitting <TAB> again, would display Start-NLBClusterNode
Now that we know how to find the CMDlet of interest, let’s see how we further use this information to formulate the exact command that we need to execute. PowerShell supports automatic expansion of the command arguments. Once you have typed in a CMDlet you can type a hyphen (-) and hit <TAB> key to automatically expand the available arguments for the given CMDlet.
1. Open a PowerShell Window with the NLB Module loaded
2. Enter > Get-NLBCluster-<TAB>
3. You will see that the “HostName” parameter will be auto-completed
4. Hit <TAB> again and you will see the text “InterfaceName” appear by the text prompt.
Using the <TAB> you can cycle through all the available arguments that the give CMDlet supports. If you went past an argument while hitting <TAB>, you can go back to it using the <SHIFT+TAB> key sequence.
This auto-completion can be further “filtered” by typing the first few characters of the argument you are interested in. For example, if I want to look for a parameter “InterfaceName”, you can try the following:
2. Type “Get-NLBCluster -i“ <TAB>
3. This will directly show you all the CMDlets that begin with the letter “I”, in this case “InterfaceName”
As you may know from the ‘Help Documentation’ section of the earlier NLB blog post that the Get-Help CMDlet is incredibly powerful.
The final thing that I would like to bring up in this section is the use of the –example argument for the help. As the name suggests, you can quickly see the examples of a given CMDlet via the “-example” argument.
Another awesome support option is the “-Online” option. This will launch the web browser with online content that is up-to-date with the latest information regarding the CMDlet (of course, this may not work if you are using a Server Core installation which cannot access Internet Explorer).
> Get-Help –Online New-NlbCluster
Rohan Mutagi & Gary JackmanClustering & High-Availability Test TeamMicrosoft
Thanks for sharing , really helpful.
Does this cmdlet apply to PS version 2.0 or only 3.0 and 4.0?
I experience the following error message when I run get-nlbcluster: The term 'Get-NlbCluster' is not recognized as the name of a cmdlet, function, script file, or operable program. How do I install the nlb module. I am using Windows server 2008 PS 3.0