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

    Args:
        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.

            .. versionadded:: 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:

        .. code-block:: bash

            salt <minion_name> win_servermanager.list_available

        Use the name in the right column of the results.

    .. code-block:: yaml

        # 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

def 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.

    Args:
        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.

            .. versionadded:: 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:

        .. code-block:: bash

            salt <minion_name> win_servermanager.list_available

        Use the name in the right column of the results.

    .. code-block:: yaml

        # 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
    '''
    ret = {'name': name,
           'result': True,
           'changes': {},
           'comment': ''}

    # Check if features is not passed, use name. Split commas
    if features is None:
        features = name.split(',')

    # Make sure features is a list, split commas
    if not isinstance(features, list):
        features = features.split(',')

    # Determine if the feature is installed
    old = __salt__['win_servermanager.list_installed']()

    rem_feat = []
    for feature in features:

        if feature in old:
            ret['changes'][feature] = 'Will be removed'
        else:
            rem_feat.append(feature)

    if rem_feat:
        rem_feat.insert(0, 'The following features are not installed:')
        ret['comment'] = '\n- '.join(rem_feat)

    if not ret['changes']:
        return ret

    if __opts__['test']:
        ret['result'] = None
        return ret

    # Remove the features
    status = __salt__['win_servermanager.remove'](
        features, remove_payload=remove_payload, restart=restart)

    ret['result'] = status['Success']

    # Some items failed to uninstall
    fail_feat = []
    rem_feat = []
    for feature in status['Features']:
        # Use get because sometimes 'Success' isn't defined such as when the
        # feature is already uninstalled
        if not status['Features'][feature].get('Success', True):
            # Show items that failed to uninstall
            fail_feat.append('- {0}'.format(feature))
        else:
            # Show items that uninstalled
            rem_feat.append('- {0}'.format(feature))

    if fail_feat:
        fail_feat.insert(0, 'Failed to remove the following:')
    if rem_feat:
        rem_feat.insert(0, 'Removed the following:')

    ret['comment'] = '\n'.join(fail_feat + rem_feat)

    # Get the changes
    new = __salt__['win_servermanager.list_installed']()
    ret['changes'] = salt.utils.data.compare_dicts(old, new)

    return ret