Windows features management helps you turn Windows parts on or off easily. It lets you add or remove tools without reinstalling Windows.
Windows features management in PowerShell
Start learning this pattern below
Jump into concepts and practice - no test required
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.
Get-WindowsFeature
Install-WindowsFeature -Name Web-Server
Uninstall-WindowsFeature -Name Web-Server
This script lists all installed Windows features, installs the Telnet Client feature, then checks if it is installed.
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;
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.
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.
Practice
Get-WindowsFeature do?Solution
Step 1: Understand the cmdlet purpose
Get-WindowsFeatureis used to view Windows features, not change them.Step 2: Identify the correct description
This cmdlet lists all features and shows if they are installed or not.Final Answer:
Lists all available Windows features and their installation status -> Option CQuick Check:
Get-WindowsFeature = List features [OK]
- Confusing Get-WindowsFeature with Install-WindowsFeature
- Thinking it restarts the system
- Assuming it removes features
Solution
Step 1: Identify the cmdlet for installing features
The correct cmdlet to install a feature isInstall-WindowsFeature.Step 2: Check the parameter usage
The feature name is passed with the-Nameparameter, soInstall-WindowsFeature -Name Web-Serveris correct.Final Answer:
Install-WindowsFeature -Name Web-Server -> Option DQuick Check:
Install-WindowsFeature -Name = install feature [OK]
- Using Get-WindowsFeature to install
- Using Add-WindowsFeature which is not a valid cmdlet
- Using Enable-WindowsFeature which does not exist
Install-WindowsFeature -Name Telnet-Client -Restart
Solution
Step 1: Understand the cmdlet and parameters
Install-WindowsFeatureinstalls the feature namedTelnet-Client. The-Restartflag tells it to restart the computer automatically if required.Step 2: Predict the command behavior
The command installs the feature and restarts if needed, no errors expected.Final Answer:
Installs Telnet-Client and restarts the computer automatically if needed -> Option BQuick Check:
Install-WindowsFeature + -Restart = install and auto restart [OK]
- Thinking -Restart is invalid
- Confusing install with removal
- Assuming no restart happens automatically
Uninstall-WindowsFeature -Name "NonExistentFeature"
What is the most likely cause?
Solution
Step 1: Analyze the error cause
The error likely occurs because the feature name "NonExistentFeature" is not valid or not installed on the system.Step 2: Check other options
Uninstalling requires administrator privileges, but the error would specify permissions if that were the issue. The cmdlet does remove installed features. The -Force parameter is optional and not required for non-existent features.Final Answer:
The feature name is incorrect or does not exist on this system -> Option AQuick Check:
Invalid feature name = error [OK]
- Running PowerShell without admin rights
- Assuming uninstall cmdlet disables only
- Adding unnecessary parameters like -Force
Solution
Step 1: Understand installing multiple features
PowerShell'sInstall-WindowsFeatureaccepts multiple feature names as a comma-separated list in the-Nameparameter, but it is recommended to use a loop for clarity and error handling.Step 2: Evaluate options
A loop withInstall-WindowsFeaturefor each feature name in an array is the best approach for scripting multiple installs. Running once with all names separated by commas is possible but less flexible. PipingGet-WindowsFeatureoutput would attempt to install all features, which is dangerous. UsingUninstall-WindowsFeaturefirst is inefficient and risky.Final Answer:
Use a loop with Install-WindowsFeature for each feature name in an array -> Option AQuick Check:
Looping Install-WindowsFeature for each feature = best practice [OK]
- Using a single command with comma-separated names without error handling
- Piping Get-WindowsFeature output to install all features
- Uninstalling features before installing unnecessarily
