How to Enable/Disable Windows Features via PowerShell or Command Line in Windows 7 (ServerManager Alternative)


2 views

When automating Windows feature management across different OS versions, you'll encounter varying tools:

  • Windows XP: sysocmgr
  • Server 2008: servermanagercmd
  • Server 2008 R2/Windows 7: Requires different approaches

While Windows 7 lacks the ServerManager module, we can use DISM (Deployment Image Servicing and Management):

# List all available features
Dism /online /Get-Features /Format:Table

# Enable a specific feature
Dism /online /Enable-Feature /FeatureName:TFTP

# Disable a feature
Dism /online /Disable-Feature /FeatureName:TelnetClient

For more PowerShell-centric solutions:

# Using WMI (Windows Management Instrumentation)
$feature = Get-WmiObject -Class Win32_OptionalFeature -Filter "Name='TelnetClient'"
if ($feature.InstallState -ne 1) {
    $feature.Install()
}

# For IIS features (requires elevation)
Import-Module WebAdministration
Add-WindowsFeature Web-Server -IncludeAllSubFeature

Common Windows 7 feature names for scripting:

Display Name Feature Name
Telnet Client TelnetClient
TFTP Client TFTP
IIS Web-Server
.NET Framework 3.5 NetFx3

For legacy system compatibility:

@echo off
:: Enable multiple features in one script
Dism /online /Enable-Feature /FeatureName:TFTP /NoRestart
Dism /online /Enable-Feature /FeatureName:TelnetClient /NoRestart
echo Windows features installed. Reboot required.
  • Always run commands as Administrator
  • Use /NoRestart parameter to prevent immediate reboots
  • Check feature states with Dism /online /Get-FeatureInfo /FeatureName:feature_name
  • For errors, consult %windir%\Logs\CBS\CBS.log

If you've scripted Windows feature management before, you'll recall sysocmgr in Windows XP and servermanagercmd in Server 2008. Windows 7 introduces a new paradigm - while Server 2008 R2 uses the PowerShell ServerManager module, this module isn't available in the client OS.

For Windows 7, Microsoft introduced the Deployment Image Servicing and Management (DISM) tool. This command-line utility can manage features even when the ServerManager module isn't present.


# List all available features
DISM /Online /Get-Features

# Enable a feature (example: Telnet Client)
DISM /Online /Enable-Feature /FeatureName:TelnetClient

# Disable a feature
DISM /Online /Disable-Feature /FeatureName:TelnetClient

While Windows 7 doesn't include ServerManager, you can still use PowerShell with WMI for some feature management:


# Get list of optional features
Get-WmiObject -Class Win32_OptionalFeature | Select-Object Name,InstallState

# Enable IIS components (example)
Import-Module ServerManager
Add-WindowsFeature Web-Server -IncludeAllSubFeature

Note that some features may require the ServerManager module, which can be installed separately if needed.

For batch deployments, consider this script that checks prerequisites first:


@echo off
SET feature=TFTP

DISM /Online /Get-FeatureInfo /FeatureName:%feature% | find "Enabled"
if %errorlevel%==0 (
    echo %feature% is already enabled
) else (
    DISM /Online /Enable-Feature /FeatureName:%feature% /NoRestart
)
  • Some features require elevation - always run as Administrator
  • Certain features may need a reboot to complete installation
  • Feature names are case-sensitive in DISM commands
  • For remote management, use PowerShell remoting or psexec

While this article focuses on Windows 7, note that Windows 8+ and Windows 10 use:


# Windows 10/11 approach
Enable-WindowsOptionalFeature -Online -FeatureName "MicrosoftWindowsPowerShellV2" -All

This demonstrates Microsoft's evolving approach to feature management across OS versions.