Powershell – Install or Uninstall Windows Server 2012 R2 feature


Check existing features

Get-WindowsFeature
Check available and installed features with the following cmdlet:

Get-WindowsFeature

To check it in a remote computer, type:

Get-WindowsFeature –ComputerName MYSERVERNAME

 
Windows Server 2012 R2 features available
These are the available features (different releases may vary output)
Powershell - Install Windows Server 2012 Feature_s001
 
Install feature
Install-WindowsFeature
To install .NET Framework 3.5 feature type:

Install-WindowsFeature NET-Framework-Core

To install .NET Framework 3.5 feature defining the corresponding source type:

Install-WindowsFeature NET-Framework-Core –Source D:\sources\sxs\

Doing it on a remote server installing all depending features:

Install-WindowsFeature NET-Framework-Core –ComputerName MYSERVERNAME -IncludeAllSubFeature

If the feature to install requires restart you can specify to do it automatically with the –Restart parameter:

Install-WindowsFeature NET-Framework-Core –ComputerName MYSERVERNAME –IncludeAllSubFeature -Restart

Note: Install-WindowsFeature alias is Add-WindowsFeature
 
Remote installation on multiple servers
To install a component on more than one server, ejecute:

$multiservers = (‘server01’,’server02’,’server03’)
ForEach ($server in $multiservers) {
Install-WindowsFeature NET-Framework-Core –ComputerName $server –IncludeAllSubFeature –Restart
}

 
Uninstall feature
Uninstall-WindowsFeature
To uninstall a feature on a remote computer and doing a restart if needed, type:

Uninstall-WindowsFeature –Name NET-Framework-Core –ComputerName MYSERVERNAME -Restart

Remove-Item alias:\show
[/code]
Note: Uninstall-WindowsFeature alias is Remove-WindowsFeature
 

In Depth
http://technet.microsoft.com/en-us/library/hh831809.aspx
http://geekswithblogs.net/Wchrabaszcz/archive/2013/09/04/how-to-install-windows-server-features-using-powershell–server.aspx
http://technet.microsoft.com/en-us/library/dn482068.aspx

Tested With
PowerShell 4.0

Advertisements
Categories: Powershell | Leave a comment

Post navigation

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: