0 votes

We have groups that have nested groups that have members.

(How our nested groups are setup. One user can be part of more than on group.)

I need one CSV with name and email address created of all the users in the highest level group emailed to me.
I'm want to setup a scheduled task to do this monthly but the only scripts I have found make a CSV for each of the nested groups and not the "all-Users" group

I would like any and all help that is given.

Thank you,

by (1.3k points)
0

Hello,

What version of Adaxes are you currently using? To check that:

  1. Launch Adaxes Administration Console.
  2. Right-click your service.
  3. Click Properties in the context menu.
  4. Adaxes version is displayed on the General tab.
0

I'm on 3.8.14823.0

1 Answer

0 votes
by (292k points)
selected by
Best answer

Hello,

Have a look at the following script from our repository: https://www.adaxes.com/script-repositor ... e-s184.htm.
For the report to include only direct group members, replace the line

$memberGuidsBytes = $Context.TargetObject.GetEx("adm-MembersGuid")

with the following:

$memberGuidsBytes = $Context.TargetObject.GetEx("adm- DirectMemberOfGuid")

To send the CSV file attached to an email notification, use the Send-MailMessage cmdlet.

Should you have difficulties updating the script to meet your needs, provide us with all the possible details on the resulting CSV file (columns, sorting, etc.) and we will help you.

0

I need the in-direct members because the "All-Users" group does not contain users directly only the groups for the offices they are in. The office groups contains the users. Also I need one CSV, that script makes a new CSV for each nested group. which is not what I need. I need the user's name and email address only in the CSV

0

Hello,

We have updated the script to meet your needs, find it below. To run the script, you can use a Custom Command, Scheduled Task, etc. configured for Group object type. In the script:

  • $csvFilePath - specifies a UNC path to the CSV file that will be created by the script;
  • $removeCSVFile - specifies whether to remove the CSV file after it has been sent;
  • $sortColumns - specifies the columns to sort by;
  • $sortDirection - specifies the sort direction;
  • $to - specifies a comma separated list of recipients of the report;
  • $subject - specifies the email message subject;
  • $message - specifies the email notification message;
  • $from - specifies the notification sender;
  • $smtpServer - specifies the SMTP server to use when sending a notification.
# CSV file settings
$csvFilePath = "C:\reports\report.csv" # TODO: modify me
$removeCSVFile = $True # TODO: modify me

# E-mail settings
$to = "recipient@domain.com" # TODO: modify me
$subject = "Group members" # TODO: modify me
$message = "Group members" # TODO: modify me
$from = "noreply@domain.com" # TODO: modify me
$smtpServer = "mail.domain.com" # TODO: modify me

function GetPropertyValue ($object, $propertyName)
{
    try
    {
        $value = $object.Get($propertyName)
    }
    catch
    {
        $value = $NULL
    }

    return $value
}

$now = [System.DateTime]::Now.ToString("yyyy.MM.dd.HH.mm.ss")
$csvFilePath = [System.String]::Format($csvFilePath, $now)

# Get group members
try
{
    $memberGuidsBytes = $Context.TargetObject.GetEx("adm-MembersGuid")
}
catch
{
    $Context.LogMessage("The group has no members. No CSV file will be created.", "Warning")
    return # Exit script
}

# Build report
$report = @()
foreach ($memberGuidBytes in $memberGuidsBytes)
{
    # Bind to the group member
    $memberGuid = New-Object "System.Guid" (, $memberGuidBytes)
    $memberGuid = $memberGuid.ToString("B")
    $memberPath = "Adaxes://<GUID=$memberGuid>"
    $member = $Context.BindToObject($memberPath)

    # Add member information to the report
    $memberName = GetPropertyValue $member "cn"
    $memberEmail = GetPropertyValue $member "mail"

    $reportEntry = New-Object PSObject
    $reportEntry | Add-Member -Name Name -Value $memberName -MemberType NoteProperty
    $reportEntry | Add-Member -Name Email -Value $memberEmail -MemberType NoteProperty    
    $report += $reportEntry
}

# Export report to CSV
$report | Sort-Object "Name" | Export-Csv -Path $csvFilePath -NoTypeInformation

# Send mail
Send-MailMessage -To $to -from $from -SmtpServer $smtpServer -Subject $subject -Body $message -Attachments $csvFilePath

if ($removeCSVFile)
{
    # Remove temporary file
    Remove-Item $csvFilePath -Force
}

Related questions

0 votes
1 answer

We have a 3rd party vendor that we are able to add users based on AD security groups. What I need to do is set a parameter for the number of available licenses and whenever ... the group is 495 I would like an email to trigger telling me to add more licenses.

asked Oct 12, 2022 by A_Pastor (70 points)
0 votes
1 answer

So this works for us however we would like to add to check if the last group is at 3 users we would like to send a seperate email but would still like all the above to continue to happen the way it is.

asked Mar 2, 2022 by Keonip (180 points)
0 votes
1 answer

I would like to on a monthly basis to email the group owner the members of each group they own for verification pruposes. i would need the group name and the name of the members.

asked Jun 3, 2021 by Derek.Axe (480 points)
0 votes
1 answer

I am trying to make a custom report that is basically the "Members of Groups" default report but instead of selecting Directory Objects, I want to select groups. The Members of ... will not work in Adaxes 2023 and later. I am running 2023.2 -- Suggestions?

asked Aug 13 by AvenuesRecovery (20 points)
0 votes
0 answers

Hi all Primary objective is to manage cloud only group membership but in a future include cloud only accounts. I've registered a Azure domain which is managed by ... /www.adaxes.com/questions/12293/add-to-365-group-automation-for-new-account-creations Thanks

asked May 31 by MinorDruid (20 points)
3,569 questions
3,259 answers
8,275 comments
547,953 users