DESKTOP

Windows Server 2008 R2 Powershell Cmdlets (part 5) - Server Manager cmdlets

2/27/2014 2:18:15 AM

5. Server Manager cmdlets

The Server Manager cmdlets are there to help the administrator with any action the Server Manager would normally allow them to perform (see Table 16).

Table 16. Server Manager cmdlets
cmdlet NameDescription
Add-WindowsFeatureThis cmdlet is used to install features
Get-WindowsFeatureThis cmdlet is used to get the list of features available. The installed features will show an [X] by them and the ones that are not installed will show []
Remove-WindowsFeatureThis cmdlet is used to remove an installed feature

With the PowerShell Server Manager cmdlets, you can add, check, and remove roles, roles services, and features from servers in your environment. Before you can have access to these cmdlets, you have to import the Server Manager module via the import-module cmdlet. Follow these steps to import the Server Manager Module:

1.
Startup PowerShell

2.
Type import-module ServerManager

3.
Once the cmdlet completes, you can check that you have access to the Server Manager cmdlets by typing get-help *windowsfeature*. Remember that the * are the wildcards and this will return all cmdlets with windowsfeature anywhere in them. A list of three cmdlets should then be listed for you as shown (see Figure 18), which will include Add-WindowsFeature, Get-WindowsFeature, and Remove-WindowsFeature.

Figure 18. The Server Manager cmdlets.

These cmdlets are very straightforward in their use and purpose as can be determined by their names. Add-WindowsFeature is the one the administrator will be using to add the roles, role services, and features; Get-Wind-owsFeature is the one that will be used to get the information about them, and Remove-WindowsFeature to remove them directly. The syntax is just as straightforward. Assume that you wanted to install the telnet client on your server. Instead of starting up Server Manager and using the wizard, you can do it directly with PowerShell. The first thing you need is the name of the feature you want to install. Sometimes, you will not know the exact name that Server Manager uses and will need to look it up. This is done with the Get-WindowsFeature cmdlet. Typing Get-WindowsFeature at the prompt will return a list with all the potential features with a column showing their display name in Server Manager and a column showing their name. The Display name column will also have an [X] next to any feature already installed. This way if you need to, you can check to see if the feature you want is already installed. The name column is what will be needed for the cmdlet to run properly. In this case, the name of the telnet client is telnet-client. Looking at the Display name column, you will see that it is not installed by default (see Figure 19). With this name, you can now call the Add-WindowsFeature cmdlet by typing Add WindowsFeature telnet-client and then hitting enter. You will then get the prompt back. Now, you try the Get-WindowsFeature cmdlet again. You can type it without an argument like you did the first time, or you can specify that you want to see the telnet client feature specifically by giving it the name and typing Get-WindowsFeature telnet-client. You will now be able to see that the telnet client has an [X] before it, showing that it has been installed (see Figure 20).

Figure 19. Telnet-Client is not installed.

Figure 20. Telnet-Client is installed.

The Remove-WindowsFeature cmdlet is the cmdlet you will be using to remove modules, as the name implies. Following the previous example, let us say you now want to remove the telnet client. Since you already know the name of the feature you want to remove, you do not need to look it up, but if you do not know the name, you could just look it up with Get WindowsFeature as described earlier. The next step is to issue the cmdlet by typing Remove-WindowsFeature telnet-client and hit enter. PowerShell will process the cmdlet and then return a summary describing if the removal was successful, if a restart is needed, and a reminder of what feature was removed (see Figure 21).

Figure 21. Removing Telnet-Client cmdlet results.

So, the question is, when would you use these features? Imagine you are the lucky administrator tasked with building up a Web server farm consisting of 15 new servers which all require IIS to be installed. Instead of trudging your way through each server one at a time and utilizing the Server Manager GUI to perform the installs, you would instead be able to create and utilize a repeatable PowerShell cmdlet or a sequence of cmdlets. Even if you decided to log on to each server and execute the cmdlets instead of utilizing the GUI, you would save a hefty amount of time in performing the installations. Now, add to this the equation the fact that you can use PowerShell’s new remoting features or even just write it once and have it available on the network, and you can see the reason why you would use it.

Other  
  •  Windows Server 2008 R2 : PowerShell V2 feature focus - Installing Powershell, Introduction to Powershell Scripting
  •  Windows Server 2008 R2 : PowerShell V2 feature focus - Introduction to Powershell
  •  Installing Windows 8 on startup VHD files (part 3) - Starting the system from the VHD, Removing VHD installations
  •  Installing Windows 8 on startup VHD files (part 2) - Creating the VHD during the installation by using DiskPart
  •  Installing Windows 8 on startup VHD files (part 1) - Creating a VHD from an existing installation
  •  Windows 8 : Upgrading or migrating from a previous version of Windows (part 4) - Migrating user data
  •  Windows 8 : Upgrading or migrating from a previous version of Windows (part 3) - Using an external hard disk or USB flash drive, Using the User State Migration Tool
  •  Windows 8 : Upgrading or migrating from a previous version of Windows (part 2) - Using removable media, Using a network connection
  •  Windows 8 : Upgrading or migrating from a previous version of Windows (part 1) - Running the Setup Wizard , Configuring your account
  •  Installing Windows 8 on a new or formatted system (part 3) - Installing Windows 8 with Windows To Go
  •  
    Top 10
    3 Tips for Maintaining Your Cell Phone Battery (part 2) - Discharge Smart, Use Smart
    3 Tips for Maintaining Your Cell Phone Battery (part 1) - Charge Smart
    OPEL MERIVA : Making a grand entrance
    FORD MONDEO 2.0 ECOBOOST : Modern Mondeo
    BMW 650i COUPE : Sexy retooling of BMW's 6-series
    BMW 120d; M135i - Finely tuned
    PHP Tutorials : Storing Images in MySQL with PHP (part 2) - Creating the HTML, Inserting the Image into MySQL
    PHP Tutorials : Storing Images in MySQL with PHP (part 1) - Why store binary files in MySQL using PHP?
    Java Tutorials : Nested For Loop (part 2) - Program to create a Two-Dimensional Array
    Java Tutorials : Nested For Loop (part 1)
    REVIEW
    - First look: Apple Watch

    - 3 Tips for Maintaining Your Cell Phone Battery (part 1)

    - 3 Tips for Maintaining Your Cell Phone Battery (part 2)
    VIDEO TUTORIAL
    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 1)

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 2)

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010 (Part 3)
    Popular Tags
    Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Biztalk Exchange Server Microsoft LynC Server Microsoft Dynamic Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Indesign Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe After Effects Adobe Photoshop Adobe Fireworks Adobe Flash Catalyst Corel Painter X CorelDRAW X5 CorelDraw 10 QuarkXPress 8 windows Phone 7 windows Phone 8 BlackBerry Android Ipad Iphone iOS