Uninstall-WindowsFeature

Uninstall and optionally remove specified roles, role services, and features from a computer that is running Windows Server 2012 R2, or from an offline virtual hard disk (VHD) on which Windows Server 2012 R2 is installed. .

Syntax
      Uninstall-WindowsFeature [-Name] Feature[] [-Restart] [-IncludeManagementTools] [-Remove]
         [-ComputerName String] [-Credential PSCredential] [-LogPath String][-WhatIf] [-Confirm] [CommonParameters]

      Uninstall-WindowsFeature [-Name] Feature[] [-Vhd String] [-IncludeManagementTools] [-Remove]
         [-ComputerName String] [-Credential PSCredential] [-LogPath String] [-WhatIf] [-Confirm] [CommonParameters]

Key
   -ComputerName
      Install one or more available features on a specified remote computer.
      This parameter accepts only one computer name. If this parameter is not added, or no computer name is specified,
      the default target is the local computer. Valid values for the parameter include a NetBIOS name, an IP address,
      or a fully qualified domain name of a remote computer that is running Windows Server

   -ConfigurationFilePath
      Provides a single path to a configuration file which specifies roles and features to be installed, and any
      configuration parameters needed. The path can be specified by using a local relative path (such as D:\myfolder)
      or by using built-in environment variables prefixed with the $env tag (such as $env:systemdrive\filename).
      A configuration file can be generated by running the arfw in Server Manager.
      If this parameter is specified, then the Name parameter cannot be used.

   -Confirm
      Prompt for confirmation before running the cmdlet.

   -Credential
      A user account that has access rights to perform this action.
      If the parameter is not added, or no value is specified, the default value is the current user.

   -IncludeAllSubFeature
      All subordinate role services, and all subfeatures of parent roles, role services, or features specified by
      the -Name parameter should be installed.

   -IncludeManagementTools
      All applicable management tools of the roles, role services, or features specified by the -Name parameter
      should be installed. Note: Although management tools are installed by default when you are installing
      features by using the arfw, management tools are not installed by default when you install features by
      using the Install-WindowsFeature cmdlet; this parameter must be added to install management tools.

   -LogPath
      Specifies a name and path to a log file. Add this parameter if the results of your command must be stored in a log.

   -Name string
      A list of features to install. This parameter does not support wildcard characters.
      If this parameter is specified, then the -ConfigurationFilePath parameter cannot be used.

   -Restart
      Specifies that the target computer is restarted automatically, if a restart is required by the installation
      process for the specified roles or features. This parameter cannot be used with the -Vhd parameter.

   -Source

      The path to feature files, if the files are not available in the local feature store of the target computer
      or VHD. Valid values for this parameter are either a network path or the path to a Windows image file (WIM).
      If you are installing roles or features on an offline VHD, you must use a mounted WIM.
      It is not necessary to mount the WIM file for installing on a running physical computer, because a WIM is
      mounted internally for deployments to a physical computer.
      Specify the path by using a local relative path, or by using built-in environment variables that are prefixed
      with the $env tag as shown in the following examples.

      If this parameter is used in combination with the -ComputerName parameter, the source path must be accessible
      by the target computer (e.g. local devices/drives/paths on the client system will cause the installation to fail).

      The path specified in this parameter is only used if the command cannot find feature files in the local
      side-by-side store of the specified target computer or VHD.
      The command searches for feature files in the following order:

         On the target computer or offline VHD.

         Path specified as the value of this parameter. If you add a UNC path, verify that the computer account of
         the target server has Read permissions on the share. The computer account should be in one of the
         following formats: DOMAIN\SERVERNAME$ or SERVER$

         Repository path specified by the Group Policy Object (GPO), Specify settings for optional component
         installation and component repair, located in Computer Configuration/Administrative Templates/System
         in Local Group Policy Editor. This Group Policy setting controls the following Windows Registry
         setting: HKLM\Software\Microsoft\Windows\CurrentVersion\Policies\Servicing\LocalSourcePath.

         Windows Update.

   -Vhd
      The path to an offline VHD.
      The path can either point to a VHD file, or to a location on which the VHD is already mounted by using
      Deployment Image Servicing and Management (DISM) tools.

      The VHD can be on a local disk on the target computer, or on a network shared folder.
      If the VHD is in a network shared folder, then the value of this parameter is a UNC path to the VHD.
      In this case, the computer account of the computer that you are using to mount the VHD must have read and
      write permissions (Read/Write permissions in File Sharing, or Full Control Security) on the shared folder,
      or the VHD will not be accessible. Local loopback UNC paths are not supported.
      Use either of the following formats for the computer account: DOMAIN\SERVERNAME$ or SERVERNAME$.

      Add the -ComputerName parameter to specify the target computer you want to use to mount the VHD.
      If the -ComputerName parameter is not specified, then the local computer is used.
      The computer that you are using to mount the VHD must be running Windows Server 2012 R2.
      Any local path, such as D:\myFolder, that is specified by using this parameter is always relative to the target computer.

   -WhatIf
      Describe what would happen if you executed the command,  without actually
      executing the command. This will also display any Windows features that
      would be installed due to dependencies.

   CommonParameters:
       -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable,
       -OutBuffer -OutVariable.

Examples

Uninstall any roles or features that are currently installed on the target server:

C:\PS> Get-WindowsFeature | Where-Object -FilterScript { $_.Installed -Eq $TRUE } | Uninstall-WindowsFeature

Remove the IIS Web Server from Server64, including all role services. The user account specified to perform the operation is ss64dom\vladtheinstaller:

C:\PS> Uninstall-WindowsFeature -Name Web-Server -ComputerName Server64 -Credential ss64dom\vladtheinstaller

Delete the feature files for any roles or features that currently are not installed on the local server:

C:\PS> Get-WindowsFeature | Where-Object -FilterScript { $_.Installed -Eq $FALSE } | Uninstall-WindowsFeature -Remove

"His departure gave Catherine the first experimental conviction that a loss may be sometimes a gain" ~ Jane Austen, Northanger Abbey

Related PowerShell Cmdlets:

Install-WindowsFeature - Install roles, role services, or features (Server 2012 R2).
Get-WindowsFeature - Retrieve roles, role services, and features.
Disable-WindowsOptionalFeature - Disable a feature in a Windows image.
Remove-WindowsCapability - Uninstall a Windows capability package from an image.


 
Copyright © SS64.com 1999-2020
Some rights reserved