Search

How to add Roles and Features using PowerShell

In this lesson, we will learn how to add Roles and Features in Windows Server using PowerShell. In this example, we are going to add "DHCP Server" Role and "Remote Server Administration Tools" Feature to a newly installed Windows Server 2025 computer using Install-WindowsFeature PowerShell cmdlet.

If you are new to Roles and Features in Windows Server, please click the following links to learn What are Roles and Features in Windows Server, Roles in Windows Server and Features in Windows Server.

Click the following links to learn how to add Roles and Features in Windows Server using Server Manager, how to Remove Roles and Features in Windows Server using Server Manager and how to remove Roles and Features using PowerShell.

Please watch below steps to learn how to add Roles and Features in a Windows Server using PowerShell Install-WindowsFeature cmdlet. In this example, we will install "DHCP Server" Role and "Remote Server Administration Tools > Role Administration Tools > DHCP Server Tools" Feature using Install-WindowsFeature PowerShell cmdlet.

Please note that you need to run PowerShell as Administrator to successfully add a Role and/or a Feature to a Windows Server. Please visit following lesson to learn how to run PowerShell as administrator in Server Core.

Step 01 – First, let us find whether DHCP Server Role is available in this Windows Server computer (OMNISECU–12) by using Get-WindowsFeature PowerShell cmdlet. Please note that the Where-Object PowerShell cmdlet is used to select the Role or Feature has its name containing "DHCP".


PS C:\jajish> Get-WindowsFeature | Where-Object {$_.name -match "DHCP" }

Display Name                                            Name                      Install State
------------                                            ----                      -------------
[ ] DHCP Server                                         DHCP                          Available
        [ ] DHCP Server Tools                           RSAT-DHCP                     Available

C:\Users\jajish>

 

Screenshot of the Get-WindowsFeature PowerShell cmdlet output is copied below.

get-windowsfeature-add-role-feature-1.jpg

We can understand from the above output of the Get-WindowsFeature cmdlet, that both "DHCP Server" Role and "DHCP Server Tools" Feature are available on this Windows Server computer.

If the "Install State" shows "Available", then the Role or Feature is available, not installed.

If the "Install State" shows "Installed", then the Role or Feature is available and installed.

Step 2 – Now, to add "DHCP Server" Role and "DHCP Server Tools" Feature on Windows Server computer OMNISECU–12, please run Install-WindowsFeature PowerShell cmdlet as shown below.


PS C:\jajish> Install-WindowsFeature -Name DHCP -ComputerName OMNISECU-12 -IncludeManagementTools -Restart

Success Restart Needed Exit Code      Feature Result
------- -------------- ---------      --------------
True    No             Success        {DHCP Server, DHCP Server Tools}                                                                                                                                                  
PS C:\jajish>


 

Please visit the following links to know the Names of the Roles in Windows Server and the Names of the Features in Windows Server.

Screenshot of the above Install-WindowsFeature PowerShell cmdlet output is copied below.

install-windowsfeature-add-role-feature.jpg

Step 3 – Now, run Get-WindowsFeature PowerShell cmdlet again to verify whether "DHCP Server" Role and "DHCP Server Tools" Feature are installed. Make sure the output of the Get-WindowsFeature PowerShell cmdlet shows the "Install State" as "Installed" for the Role and Feature.


PS C:\jajish> Get-WindowsFeature | Where-Object {$_.name -match "DHCP" }

Display Name                                            Name                       Install State
------------                                            ----                       -------------
[X] DHCP Server                                         DHCP                           Installed
        [X] DHCP Server Tools                           RSAT-DHCP                      Installed    

 

Screenshot of the above Get-WindowsFeature PowerShell cmdlet output is copied below.

get-windowsfeature-add-role-feature-2.jpg

The selected Role and Feature are now added to the destination Windows Server.

Written by Jajish Thomas.
Last updated on 10th July, 2024.

 

Related Tutorials
Introduction to Windows Server 2025
Minimum hardware requirements for Windows Server 2025
New features of Windows Server 2025
How to download Windows Server 2025 Preview iso file
How to install Windows Server 2025
Differences between Server Core and GUI (Desktop Experience)
Default GUI tools in Server Core
How to run PowerShell as administrator
How to run PowerShell as administrator in Server Core
How to find the PowerShell version in Server Core and Desktop experience
How to add Network icon to desktop in Windows Server 2025
How to add Computer (This PC) icon to desktop in Windows Server 2025
How to rename a computer using Windows Explorer
How to rename computer using "Rename-Computer" PowerShell Cmdlet
How to configure IPv4 Address in Windows Server 2025
How to configure IPv4 address in Windows Server 2025 using PowerShell Cmdlets
How to configure IPv6 Address in Windows Server 2025
How to configure IPv6 Address in Windows Server 2025 using PowerShell
What is MMC (Microsoft Management Console) and what are MMC snapin files
Add a snapin to MMC console
What are Roles and Features and difference between Roles and Features in Windows Server
Roles in Windows Server
Features in Windows Server
How to add Roles and Features in Windows Server
How to Remove Roles and Features in Windows Server
How to add Roles and Features using PowerShell
How to remove Roles and Features using PowerShell
Different types of computer hardware devices
What is a Driver Software
What is Device Manager and how to open Device Manager
What is Plug and Play (PnP)
How to scan for hardware changes using Device Manager and pnputil.exe
How to disable a device using Device Manager
How to disable a device using PowerShell Disable-PnpDevice Cmdlet
How to enable a device using PowerShell Enable-PnpDevice Cmdlet
How to update drivers using Device Manager
What is Driver Signing in Windows Operating Systems
What is Roll back of a driver and how to Roll Back a driver
How to uninstall a device using Device Manager
What are File attributes in Windows Operating Systems
attrib command in Windows
How to hide files and folders using Windows File Explorer
How to hide files and folders using attrib.exe command
How to view hidden files using Windows File Explorer
What are file name extensions
What are known file extensions and how to view known file extensions
How to associate a file name extension with an app
Hide or Show known file name extensions in Windows Server 2025
Hide or Show protected operating system files in Windows Server 2025
What are multi–user Operating Systems (OS) and multi–task Operating Systems (OS)
What are local user accounts and local groups in Windows Server
Different types of user accounts in Windows Server
How to create a local user in Windows Server
How to create a local user in Windows Server using New-LocalUser PowerShell cmdlet
How to force a local user to change password on next login
How to enable or disable a local user account
How to allow or prevent a local user to change password
What are Security Principals and SIDs
How to find SIDs of local user accounts