# salt.states.win_servermanager

Manage Windows features via the ServerManager powershell module. Can install and remove roles/features.

maintainer:

  Shane Lee <slee@saltstack.com>

platform:

  Windows Server 2008R2 or greater

depends:

  win_servermanager.install

depends:

  win_servermanager.remove

salt.states.win_servermanager.installed(name, features=None, recurse=False, restart=False, source=None, exclude=None, **kwargs)

  Install the windows feature. To install a single feature, use the `name` parameter. To install multiple features, use the `features` parameter.

  Note

  Some features require reboot after un/installation. If so, until the server is restarted other features can not be installed!

  Parameters:

    - name (str) --

      Short name of the feature (the right column in win_servermanager.list_available). This can be a single feature or a string of features in a comma delimited list (no spaces)

      Note

      A list is not allowed in the name parameter of any state. Use the `features` parameter if you want to pass the features as a list

    - features (Optional[list]) --

      A list of features to install. If this is passed it will be used instead of the `name` parameter.

      Added in version 2018.3.0.

    - recurse (Optional[bool]) -- Install all sub-features as well. If the feature is installed but one of its sub-features are not installed set this will install additional sub-features. This argument was previously renamed from `force`. To ensure backwards compatibility `force` will continue to work but please update your states to use the preferred `recurse` arg.

    - source (Optional[str]) -- Path to the source files if missing from the target system. None means that the system will use windows update services to find the required files. Default is None

    - restart (Optional[bool]) -- Restarts the computer when installation is complete, if required by the role/feature installed. Default is False

    - exclude (Optional[str]) --

      The name of the feature to exclude when installing the named feature. This can be a single feature, a string of features in a comma-delimited list (no spaces), or a list of features.

      Warning

      As there is no exclude option for the `Add-WindowsFeature` or `Install-WindowsFeature` PowerShell commands the features named in `exclude` will be installed with other sub-features and will then be removed. If the feature named in ``exclude`` is not a sub-feature of one of the installed items it will still be removed.

  Example

  Do not use the role or feature names mentioned in the PKGMGR documentation. To get a list of available roles and features run the following command:

      salt <minion_name> win_servermanager.list_available

  Use the name in the right column of the results.

      # Installs the IIS Web Server Role (Web-Server)
      IIS-WebServerRole:
        win_servermanager.installed:
          - recurse: True
          - name: Web-Server

      # Install multiple features, exclude the Web-Service
      install_multiple_features:
        win_servermanager.installed:
          - recurse: True
          - features:
            - RemoteAccess
            - XPS-Viewer
            - SNMP-Service
          - exclude:
            - Web-Server

salt.states.win_servermanager.removed(name, features=None, remove_payload=False, restart=False)

  Remove the windows feature To remove a single feature, use the `name` parameter. To remove multiple features, use the `features` parameter.

  Parameters:

    - name (str) --

      Short name of the feature (the right column in win_servermanager.list_available). This can be a single feature or a string of features in a comma-delimited list (no spaces)

      Note

      A list is not allowed in the name parameter of any state. Use the `features` parameter if you want to pass the features as a list

    - features (Optional[list]) --

      A list of features to remove. If this is passed it will be used instead of the `name` parameter.

      Added in version 2018.3.0.

    - remove_payload (Optional[bool]) -- True will cause the feature to be removed from the side-by-side store. To install the feature in the future you will need to specify the `source`

    - restart (Optional[bool]) -- Restarts the computer when uninstall is complete if required by the role/feature uninstall. Default is False

  Note

  Some features require a reboot after uninstall. If so the feature will not be completely uninstalled until the server is restarted.

  Example

  Do not use the role or feature names mentioned in the PKGMGR documentation. To get a list of available roles and features run the following command:

      salt <minion_name> win_servermanager.list_available

  Use the name in the right column of the results.

      # Uninstall the IIS Web Server Rol (Web-Server)
      IIS-WebserverRole:
        win_servermanager.removed:
          - name: Web-Server

      # Uninstall multiple features, reboot if required
      uninstall_multiple_features:
        win_servermanager.removed:
          - features:
            - RemoteAccess
            - XPX-Viewer
            - SNMP-Service
          - restart: True