In its current revision, query functionality is present, but not as elegant as the "win_domain_user" module where values, such as, "present" and "absent" are returned using a "query" state.
Problems
What problems exist that this proposal will solve?
Add query functionality to module that gives "present" or "absent" status, rather than fatal error massage.
Solution proposal
Re-structure current code to add functionality to module.
Insert code in snippets if you would like as shown.
Proposal: Add graceful query state to win_domain_group module
Author: Christopher Phillip <@cphillipsmcp>
Date: 2019-11-22
Motivation
In its current revision, query functionality is present, but not as elegant as the "win_domain_user" module where values, such as, "present" and "absent" are returned using a "query" state.
Problems
What problems exist that this proposal will solve?
Solution proposal
... if (-not $check_mode) { $group = Get-ADGroup -Filter {Name -eq $name} -Properties * @extra_args if (!$group) { $result.name = $name $result.msg = "Group '$name' is absent" $result.state = "absent" } else { $result.sid = $group.SID.Value $result.description = $group.Description $result.distinguished_name = $group.DistinguishedName $result.display_name = $group.DisplayName $result.name = $group.Name $result.canonical_name = $group.CanonicalName $result.guid = $group.ObjectGUID $result.protected_from_accidental_deletion = $group.ProtectedFromAccidentalDeletion $result.managed_by = $group.ManagedBy $result.group_scope = ($group.GroupScope).ToString() $result.category = ($group.GroupCategory).ToString() $result.msg = "Group '$name' is present" $result.state = "present"