The Install-windowsfeature
cmdlet is a powerful tool for system administrators managing Windows Server environments. This command allows you to install roles, role services, and features on local or remote servers, streamlining server configuration and management. This guide provides a comprehensive overview of the Install-WindowsFeature
cmdlet, including its syntax, parameters, and practical examples.
Understanding Install-WindowsFeature Functionality
Install-WindowsFeature
offers a command-line alternative to the graphical Server Manager for installing server roles and features. A key difference is that Install-WindowsFeature
doesn’t automatically install management tools. You need to explicitly include the -IncludeManagementTools
parameter to install necessary snap-ins and other management utilities. This cmdlet requires administrator privileges, meaning you must run PowerShell as an administrator to utilize it.
Syntax Breakdown
The Install-WindowsFeature
cmdlet supports several syntax variations:
Install-WindowsFeature [-Name] <feature> [-Restart] [-IncludeAllSubFeature] [-IncludeManagementTools] [-Source <string>] [-ComputerName <string>] [-Credential <pscredential>] [-LogPath <string>] [-WhatIf] [-Confirm] [<commonparameters>]
Install-WindowsFeature [-Name] <feature> -Vhd <string> [-IncludeAllSubFeature] [-IncludeManagementTools] [-Source <string>] [-ComputerName <string>] [-Credential <pscredential>] [-LogPath <string>] [-WhatIf] [-Confirm] [<commonparameters>]
Install-WindowsFeature -ConfigurationFilePath <string> [-Vhd <string>] [-Restart] [-Source <string>] [-ComputerName <string>] [-Credential <pscredential>] [-LogPath <string>] [-WhatIf] [-Confirm] [<commonparameters>]
Parameter Deep Dive
Let’s explore the key parameters of the Install-WindowsFeature
cmdlet:
-Name
: Specifies the feature(s) to install. Avoid wildcard characters. Cannot be used with-ConfigurationFilePath
.-ComputerName
: Targets a remote computer for installation. Accepts NetBIOS names, IP addresses, or FQDNs. Requires-Credential
when using an IP address unless configured for HTTPS or in the TrustedHosts list. Defaults to the local computer if omitted.-ConfigurationFilePath
: Uses a configuration file (XML) to define roles, features, and parameters for installation. Generated by Server Manager’s “Export configuration settings.” Cannot be used with-Name
.-IncludeAllSubFeature
: Installs all sub-features and role services of the specified feature.-IncludeManagementTools
: Installs associated management tools for the specified feature. Crucial for administering the installed feature.-Restart
: Automatically restarts the target computer if required after installation. Cannot be used with-Vhd
.-Source
: Specifies an alternate source path for feature files (network path or WIM file). Used when files aren’t in the local feature store.-Vhd
: Targets an offline VHD for installation. Requires a mounted WIM for offline VHDs.-Credential
: Provides alternate credentials for accessing remote computers.
*-LogPath
: Designates a file path for logging installation results.-WhatIf
: Simulates the installation without actually making changes. Useful for testing.-Confirm
: Prompts for confirmation before executing the command.
Practical Examples:
Installing Web Server with Subfeatures:
Install-WindowsFeature -Name Web-Server -IncludeAllSubFeature
This command installs the Web Server (IIS) role along with all its sub-features on the local computer.
Installing Features on a Remote Server:
Install-WindowsFeature -Name DNS -ComputerName Server01 -IncludeManagementTools -Credential domainadministrator
This installs the DNS Server role with management tools on the remote server “Server01” using specified credentials.
Installing Features from a Configuration File:
Install-WindowsFeature -ConfigurationFilePath C:serverconfig.xml
This command installs features based on the specifications within the “serverconfig.xml” configuration file.
Installing Features from a Specific Source:
Install-WindowsFeature -Name Telnet-Client -Source \fileserversourcessxs
This installs the Telnet Client feature, using the specified network share as the source for installation files.
Conclusion
The Install-WindowsFeature
cmdlet is an essential tool for efficient Windows Server management. By understanding its syntax and parameters, you can automate the installation of server roles and features, saving time and ensuring consistency across your environment. Remember to consult the official Microsoft documentation for the most up-to-date information and detailed parameter explanations.