Learn this information to learn to set up Home windows Server roles, options, and roles administration instruments with the PowerShell Set up-WindowsFeature command.
Overview
Most SysAdmins set up Home windows server roles with Server Supervisor. Server Supervisor is nice as a result of it could possibly additionally deploy roles on distant servers.
Nonetheless, PowerShell affords a sooner strategy to carry out the duty on a number of servers. Nonetheless, you want the function’s identify to put in it with PowerShell.
In step 1 beneath, I’ll present you the right way to discover the identify for any Server function you want to set up. After that, I’ll present you the right way to set up the function.
Activity 1: Get the Function’s Identify with Get-WindowsFeature
To seek out the identify of a job, run the Get-WindowsFeature command and specify any phrase within the function. To specify the phrase within the function, use a * wildcard earlier than and after the phrase.
For instance, to search out the function identify for Lively Listing Area Providers – use any work in “Lively Listing Area Providers,” for instance “listing” – with Get-WindowsFeature.
Right here is the complete command.
Get-WindowsFeature *area* | Format-Desk -AutoSize
I piped the output of the Get-WindowsFeature command to Format-Desk to keep away from truncating the outcomes.
The command returns all server roles that include the phrase ‘listing’. If a job is just not put in but its Set up State shows the Accessible.
To put in the function, use the function’s identify within the Identify column.
One other instance is Hyper-V. If you want to set up the Hyper-V supervisor function with out putting in the Hyper-V function, get the identify of the function by working the command beneath:
Get-WindowsFeature *Hyper-V* | Format-Desk -AutoSize
The command returns all Hyper-V roles, together with its administration instruments. On the Show Identify column, “Hyper-V Administration Instruments” and its SubFeatures – “Hyper-V GUI Administration Instruments” and “Hyper-V Module for Home windows PowerShell” – are checked.
This means that the “Hyper-V Administration Instruments” are put in on this server as confirmed by the “Set up State” column.
When you run the command with a phrase or phrase nevertheless it doesn’t return any function identify, attempt one other phrase.
Lastly, if you want to set up roles admin instruments with out putting in the function, as I already defined, you may get the identify of a particular administration software with the strategy I defined above. Nonetheless, to return a listing of all administration instruments, run the Get-WindowsFeature command with *RSAT*.
Get-WindowsFeature *RSAT* | Format-Desk -AutoSize
I’ve highlighted some widespread function admin instruments for Lively Listing Area Providers (AD DS) and “Failover Cluster Administration Instruments.”
Activity 2: Set up the Function with Set up-WindowsFeature
After getting the identify of the function, use the Set up-WindowsFeature command to deploy the function.
For instance, I’ll run the command beneath to put in the Hyper-V Supervisor with out putting in the Hyper-V function.
Set up-WindowsFeature -Identify RSAT-Hyper-V-Instruments
In one other instance to put in the Failover Cluster Administration Device, I’ll use the get-winowsfeature command beneath to search out the function identify.
Get-WindowsFeature '*clustering*' | Format-Desk -AutoSize
Then, set up the Clustering admin instruments and all its sub-features with this command. By the best way, I’ve already put in the clustering administration software on the server I ran the above command.
Set up-WindowsFeature -Identify RSAT-Clustering
Lastly, if you want to set up any Home windows Server function on a number of computer systems, you possibly can checklist the names of the computer systems on a textual content file. Then, use the script beneath to deploy the roles on the servers.
Lists the names of the servers on the textual content file as proven in my screenshot beneath.
I’ve included feedback earlier than every command to clarify what the command does. All texts beginning with # are feedback.
#Get a listing of all of the servers from the textual content file and save them within the $Servers variable$Servers = Get-Content material <path to the textual content file>
#Save the area credential to make use of in putting in the roles within the $Credential parameter
$Credential = Get-Credential domainnameusername
#Set up the roles on all of the servers
#This script installs the DNS and Lively Listing admin instrumentsForEach ($Server in $Servers) {Invoke-Command -ComputerName $Server { Set up-WindowsFeature -Identify "RSAT-ADDS", "RSAT-DNS-Server" } -Credential $Credential -Verbose}
The screenshot beneath exhibits the results of the above script in motion. I used the script to put in the AD DS and DNS administration instruments on two servers.
The command’s outcomes present whether or not the set up was profitable and if the server requires a restart.
Activity 3: Uninstall Roles with Take away-WindowsFeature
If you want to uninstall or take away a Home windows Server function, use the Take away-WindowsFeature command. The instance beneath removes the AD DS and DNS administration instruments from one of many servers the place the roles have been put in in step 2.
The command beneath was executed remotely. When you’re working the command regionally, use Take away-WindowsFeature -Identify “RSAT-ADDS”, “RSAT-DNS-Server” with out the Invoke-Command command.
Invoke-Command -ComputerName IPMvVMM { Take away-WindowsFeature -Identify "RSAT-ADDS", "RSAT-DNS-Server" } -Credential $Credential -Verbos
Conclusion
PowerShell offers a strategy to automate the set up of Home windows Server roles on a number of servers. Nonetheless, to put in a Home windows Server function, you require the function’s identify.
In the meantime, to get the identify of a job, run the Get-WindowsFeature command. Then, set up the function with the Set up-WindowsFeature command.