0 votes

Hello, I currently have a working script that lists out ALL users disabled in the last 30 days. I am trying to adjust the parameter to ONLY include subordinates of a certain person or filter by departments. I'm assuming the script is taking precedence, so the parameter isn't working. Am I able to adjust it through the report options in Adaxes, or how would I alter the script? Is there an easier way to do this? TIA

Current script:

$days = 30 

# Bind to the directory object representing the General Log
$path = $Context.GetWellKnownContainerPath("ServiceLog")
$serviceLog = $Context.BindToObject($path)

$generalLog = $serviceLog.GeneralLog
if ($days -ne 0)
{
   $generalLog.StartDateTime = (Get-Date).AddDays(-$days)
   $generalLog.EndDateTime = Get-Date
}

# Get the log records
$log = $generalLog.Log
$records = $log.GetPage(0)

# Build filter to search for disabled users
$guidComparer = $Context.CreatePropertyValueComparer("objectGuid")
$guids = New-Object System.Collections.Generic.HashSet[byte[]] @($guidComparer)

foreach ($record in $records)
{
    if ($Context.Items.Aborted)
    {
        return
    }

    if (($record.TargetObjectType -ne "user") -or ($record.TargetObjectGuid -eq $NULL))
    {
        continue
    }

    $operationTypes = $record.GetOperationTypes()
    if ($operationTypes -notcontains "disable account")
    {
        continue
    }

    # Get GUID
    $guidBytes = ([Guid]$record.TargetObjectGuid).ToByteArray()
    $guids.Add($guidBytes)
}

$searcher = $Context.CreateGuidBasedSearcher(@($guids))
$searcher.Criteria = New-AdmCriteria -Type "user" -Expression {accountDisabled -eq $true}
$Context.Items.Add($searcher)
by (40 points)
0

Hello Milan,

What exactly do you mean by subordinates of a certain person or filter by departments? How exactly do you see the options working? Please, describe the desired behavior in all the possible details with live examples.

0

Hi, "subordinates" meaning all users under a certain manager, and all users under those managers, instead of just "direct reports" which is only the users directly under a manager. This report already exists in Adaxes, I am simply just trying to pull a report for a specific department (or manager since that manager is part of that department), within the past 30 days.

0

Hello Milan,

Do we understand correctly that you want to select the manager manually via a parameter when generating the report? What should be done in case if the specified manager does not have a department?

Please log in or register to answer this question.

Related questions

0 votes
0 answers

We have been checking to see who users were most recently disabled so we can manually check a few things. Here is the code I used to get that information using the ... report $Context.SendMail($to, $subject, $NULL, $htmlBody) } I hope someone finds it useful!

asked Jan 8, 2015 by mobosys (290 points)
0 votes
1 answer

For example: This integration with SAP SuccessFactors/Active Directory will create the users without the knowledge of Adaxes but we still want to do automation around creating ... created users report and run this automation based on the result of the report?

asked Feb 7 by DarrenFisk (100 points)
0 votes
1 answer

Is it possible to run a report to get users disabled in the last 24 hours?

asked Jun 10, 2020 by peggleg (110 points)
0 votes
1 answer

We have four OUs in Active Directory (Pending Deletion, Disabled with Mail Delegates, Disabled with HR Extensions and Disabled_Temp_Leave) that users are moved to prior to their eventual ... past 7 days have been moved to one of 4 of these OUs. Thanks!

asked Jun 3, 2021 by RayBilyk (240 points)
0 votes
1 answer

Hi, I try to make a report for our SAM to show all users with a specific license. But I fail to even find anything. I tried, among many ... .DirectorySearcher.AppendFilter("(adm-O365AccountLicenses=POWER_BI_STANDARD)") But I get nothing. Please advice.

asked May 20, 2021 by KristofferJ (80 points)
3,662 questions
3,349 answers
8,451 comments
549,143 users