0
0
PowerShellscripting~5 mins

Windows features management in PowerShell

Choose your learning style9 modes available
Introduction

Windows features management helps you turn Windows parts on or off easily. It lets you add or remove tools without reinstalling Windows.

You want to add a new Windows feature like IIS web server for testing websites.
You need to remove unused features to free up space or improve security.
You want to check which Windows features are currently installed on your computer.
You want to enable features needed by a program before installing it.
You want to automate feature changes on many computers at once.
Syntax
PowerShell
Get-WindowsFeature
Install-WindowsFeature -Name <FeatureName>
Uninstall-WindowsFeature -Name <FeatureName>

Use Get-WindowsFeature to list all features and their status.

Use Install-WindowsFeature to add a feature and Uninstall-WindowsFeature to remove it.

Examples
Shows all Windows features and if they are installed or not.
PowerShell
Get-WindowsFeature
Installs the IIS web server feature.
PowerShell
Install-WindowsFeature -Name Web-Server
Removes the IIS web server feature.
PowerShell
Uninstall-WindowsFeature -Name Web-Server
Sample Program

This script lists all installed Windows features, installs the Telnet Client feature, then checks if it is installed.

PowerShell
Write-Host "Listing all Windows features:";
Get-WindowsFeature | Where-Object {$_.Installed -eq $true} | Select-Object DisplayName, Name;

Write-Host "\nInstalling Telnet Client feature...";
Install-WindowsFeature -Name Telnet-Client | Out-Null;

Write-Host "\nChecking if Telnet Client is installed:";
Get-WindowsFeature -Name Telnet-Client | Select-Object DisplayName, Installed;
OutputSuccess
Important Notes

You need to run PowerShell as Administrator to install or remove features.

Some features require a system restart after installation or removal.

Not all Windows editions support all features.

Summary

Windows features management lets you add or remove Windows parts easily.

Use Get-WindowsFeature to see features and Install-WindowsFeature or Uninstall-WindowsFeature to change them.

Run PowerShell as admin and check if a restart is needed after changes.