Bird
Raised Fist0
PowerShellscripting~20 mins

Windows features management in PowerShell - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Windows Features Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
Check the output of listing Windows features
What is the output of this PowerShell command when run on a Windows machine with IIS installed?
Get-WindowsFeature -Name Web-Server | Select-Object Name, InstallState
PowerShell
Get-WindowsFeature -Name Web-Server | Select-Object Name, InstallState
A
[Name] Web-Server
[InstallState] Disabled
B
[Name] Web-Server
[InstallState] Removed
C
[Name] Web-Server
[InstallState] Available
D
[Name] Web-Server
[InstallState] Installed
Attempts:
2 left
💡 Hint
Think about what 'InstallState' shows when a feature is installed.
📝 Syntax
intermediate
2:00remaining
Identify the correct syntax to install a Windows feature
Which PowerShell command correctly installs the Windows feature 'Telnet-Client'?
AAdd-WindowsFeature -Name Telnet-Client
BInstall-WindowsFeature -Name Telnet-Client
CEnable-WindowsFeature Telnet-Client
DInstall-WindowsFeature Telnet-Client
Attempts:
2 left
💡 Hint
Check the official parameter name for specifying the feature.
🔧 Debug
advanced
2:00remaining
Find the error in this feature removal script
This script is intended to remove the 'Telnet-Client' feature but fails with an error. What is the cause?
Remove-WindowsFeature Telnet-Client
PowerShell
Remove-WindowsFeature Telnet-Client
AThe cmdlet requires administrative privileges; running without admin causes failure.
BThe feature name must be passed with '-Name' parameter, so it should be 'Remove-WindowsFeature -Name Telnet-Client'.
CThe cmdlet 'Remove-WindowsFeature' does not exist; the correct cmdlet is 'Uninstall-WindowsFeature'.
DThe feature cannot be removed while in use; the script needs to stop dependent services first.
Attempts:
2 left
💡 Hint
Check the official cmdlet names for removing Windows features.
🚀 Application
advanced
3:00remaining
Script to check and install a feature if missing
You want a PowerShell script that checks if the 'Web-Server' feature is installed, and if not, installs it silently. Which script achieves this?
Aif ((Get-WindowsFeature -Name Web-Server).InstallState -ne 'Installed') { Install-WindowsFeature -Name Web-Server -IncludeManagementTools -Restart:$false }
Bif ((Get-WindowsFeature Web-Server).InstallState -eq 'Available') { Install-WindowsFeature Web-Server }
Cif ((Get-WindowsFeature -Name Web-Server).InstallState -eq 'Removed') { Install-WindowsFeature -Name Web-Server -IncludeAllSubFeature }
Dif ((Get-WindowsFeature -Name Web-Server).InstallState -ne 'Installed') { Install-WindowsFeature -Name Web-Server -IncludeManagementTools -Restart }
Attempts:
2 left
💡 Hint
Check the InstallState property and the parameters for silent install without restart.
🧠 Conceptual
expert
3:00remaining
Understanding feature states and their meanings
Which of the following correctly describes the meaning of the 'InstallState' values returned by 'Get-WindowsFeature'?
A'Installed' means the feature is active; 'Available' means it can be installed; 'Removed' means it is not installed but available; 'Disabled' means the feature is not installed and blocked from installation.
B'Installed' means the feature is active; 'Available' means it can be installed; 'Removed' means it is not present and cannot be installed; 'Disabled' means the feature is blocked.
C'Installed' means the feature is active; 'Available' means it is installed but inactive; 'Removed' means it is uninstalled; 'Disabled' means it is deprecated.
D'Installed' means the feature is active; 'Available' means it is deprecated; 'Removed' means it is active but hidden; 'Disabled' means it is inactive.
Attempts:
2 left
💡 Hint
Think about which states allow installation and which block it.

Practice

(1/5)
1. What does the PowerShell cmdlet Get-WindowsFeature do?
easy
A. Restarts the computer after feature changes
B. Installs a new Windows feature
C. Lists all available Windows features and their installation status
D. Removes an installed Windows feature

Solution

  1. Step 1: Understand the cmdlet purpose

    Get-WindowsFeature is used to view Windows features, not change them.
  2. Step 2: Identify the correct description

    This cmdlet lists all features and shows if they are installed or not.
  3. Final Answer:

    Lists all available Windows features and their installation status -> Option C
  4. Quick Check:

    Get-WindowsFeature = List features [OK]
Hint: Get-WindowsFeature always shows features, never installs or removes [OK]
Common Mistakes:
  • Confusing Get-WindowsFeature with Install-WindowsFeature
  • Thinking it restarts the system
  • Assuming it removes features
2. Which of the following is the correct syntax to install the Windows feature named 'Web-Server' using PowerShell?
easy
A. Enable-WindowsFeature -Feature Web-Server
B. Get-WindowsFeature -Install Web-Server
C. Add-WindowsFeature Web-Server
D. Install-WindowsFeature -Name Web-Server

Solution

  1. Step 1: Identify the cmdlet for installing features

    The correct cmdlet to install a feature is Install-WindowsFeature.
  2. Step 2: Check the parameter usage

    The feature name is passed with the -Name parameter, so Install-WindowsFeature -Name Web-Server is correct.
  3. Final Answer:

    Install-WindowsFeature -Name Web-Server -> Option D
  4. Quick Check:

    Install-WindowsFeature -Name = install feature [OK]
Hint: Use Install-WindowsFeature with -Name to install features [OK]
Common Mistakes:
  • Using Get-WindowsFeature to install
  • Using Add-WindowsFeature which is not a valid cmdlet
  • Using Enable-WindowsFeature which does not exist
3. What will be the output of this PowerShell command?
Install-WindowsFeature -Name Telnet-Client -Restart
medium
A. Removes Telnet-Client and restarts the computer
B. Installs Telnet-Client and restarts the computer automatically if needed
C. Only checks if Telnet-Client is installed, no changes made
D. Throws an error because -Restart is not a valid parameter

Solution

  1. Step 1: Understand the cmdlet and parameters

    Install-WindowsFeature installs the feature named Telnet-Client. The -Restart flag tells it to restart the computer automatically if required.
  2. Step 2: Predict the command behavior

    The command installs the feature and restarts if needed, no errors expected.
  3. Final Answer:

    Installs Telnet-Client and restarts the computer automatically if needed -> Option B
  4. Quick Check:

    Install-WindowsFeature + -Restart = install and auto restart [OK]
Hint: Use -Restart to auto reboot after feature install if needed [OK]
Common Mistakes:
  • Thinking -Restart is invalid
  • Confusing install with removal
  • Assuming no restart happens automatically
4. You run this command but get an error:
Uninstall-WindowsFeature -Name "NonExistentFeature"

What is the most likely cause?
medium
A. The feature name is incorrect or does not exist on this system
B. You need to run PowerShell as a normal user, not admin
C. Uninstall-WindowsFeature cannot remove features, only disables them
D. The command syntax is missing the -Force parameter

Solution

  1. Step 1: Analyze the error cause

    The error likely occurs because the feature name "NonExistentFeature" is not valid or not installed on the system.
  2. 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.
  3. Final Answer:

    The feature name is incorrect or does not exist on this system -> Option A
  4. Quick Check:

    Invalid feature name = error [OK]
Hint: Check feature name spelling and existence before uninstalling [OK]
Common Mistakes:
  • Running PowerShell without admin rights
  • Assuming uninstall cmdlet disables only
  • Adding unnecessary parameters like -Force
5. You want to write a script that installs multiple Windows features: 'Web-Server', 'Telnet-Client', and 'RSAT'. Which is the best PowerShell approach?
hard
A. Use a loop with Install-WindowsFeature for each feature name in an array
B. Run Install-WindowsFeature once with all feature names separated by commas
C. Run Get-WindowsFeature and pipe output to Install-WindowsFeature
D. Use Uninstall-WindowsFeature first, then Install-WindowsFeature for each feature

Solution

  1. Step 1: Understand installing multiple features

    PowerShell's Install-WindowsFeature accepts multiple feature names as a comma-separated list in the -Name parameter, but it is recommended to use a loop for clarity and error handling.
  2. Step 2: Evaluate options

    A loop with Install-WindowsFeature for 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. Piping Get-WindowsFeature output would attempt to install all features, which is dangerous. Using Uninstall-WindowsFeature first is inefficient and risky.
  3. Final Answer:

    Use a loop with Install-WindowsFeature for each feature name in an array -> Option A
  4. Quick Check:

    Looping Install-WindowsFeature for each feature = best practice [OK]
Hint: Use a loop to install multiple features individually for better control [OK]
Common Mistakes:
  • Using a single command with comma-separated names without error handling
  • Piping Get-WindowsFeature output to install all features
  • Uninstalling features before installing unnecessarily