WFA command for querying Active Directory user groups

Below is the source code of a OnCommand Workflow Automation command that searches the Active Directory for a specific user group.

Input from the Workflow should be: DOMAIN\usergroup
Output would be: found or not found with error (Workflow should be stopped)
Installation: Just add a new command to WFA and copy/paste the below source code into the code window. Additionally install the Windows Feature “Active Directory module for Windows PowerShell” onto the WFA Server.

param (
[parameter(Mandatory=$true, HelpMessage=”AD group to check for”)]


Get-WFALogger -Info -message $(“Checking for AD group ” + $ADgroup)

$pos = $ADgroup.IndexOf(“\”)
$groupname = $ADgroup.Substring($pos+1)

# Get the latest job which moves the specified volume to the specified aggregate
$result = get-adgroup -Filter {SamAccountName -eq $groupname}

Get-WFALogger -Info -message $(“Specified AD group was not found”)
Set-WfaCommandProgress -Total 1 -Current 0 -ProgressPercentage 100 -Note “AD group was not found”
throw “Failed to find AD group ‘” + $ADgroup + “‘”
Get-WFALogger -Info -message $(“Found specified AD group”)

Set-WfaCommandProgress -Total 1 -Current 1 -ProgressPercentage 100


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s