0 votes

I have a fairly simple function that I want to convert to a report in Adaxes that others can use The PowerShell function as it currently exists

function Get-Groups {
    [CmdletBinding()]
    param (
        [Parameter(Mandatory = $true,
            Position = 0)]
        [String]
        $Username,
        [switch]
        $IncludeDefault,
        [switch]
        $IncludeDescription
    )

    $OmitList = 'Authenticated Users', 'Certificate Service DCOM Access', 'Domain Users', 'Everyone', 'Medium Plus Mandatory Level', 'Pre-Windows 2000 Compatible Access', 'Service asserted identity', 'This Organization', 'Users'

    $GroupList = Get-ADAccountAuthorizationGroup $Username | Sort-Object SamAccountName
    if (-not $IncludeDefault) {
        $GroupList = $GroupList | Where-Object { $_.SamAccountName -notin $OmitList }
    }
    if ($IncludeDescription) {
        $GroupList = $GroupList | ForEach-Object { Get-ADGroup $_.SamAccountName -Properties Description | Select-Object SamAccountName, Description }
    }
    else {
        $GroupList = $GroupList | Select-Object -ExpandProperty SamAccountName
    }
    $GroupList
}

But I'm struggling with just getting the data to the report. I created the report with two parameters image and the following script (for now, really just trying to figure out how to properly get the data over)

$OmitList = 'Authenticated Users', 'Certificate Service DCOM Access', 'Domain Users', 'Everyone', 'Medium Plus Mandatory Level', 'Pre-Windows 2000 Compatible Access', 'Service asserted identity', 'This Organization', 'Users'
$Username = $Context.GetParameterValue('param-User')
$IncludeDefault = $Context.GetParameterValue('param-IncludeDefault')
$GroupList = Get-ADAccountAuthorizationGroup $Username | Sort-Object SamAccountName
#if (-not $IncludeDefault) {
    $GroupList = $GroupList | Where-Object { $_.SamAccountName -notin $OmitList }
#}
$objectList = $GroupList | ForEach-Object { Get-ADGroup $_.SamAccountName -Properties Description | Select-Object SamAccountName, Description }
$Context.Items.Add($objectList)

This obviously doesn't work and I've been trying different methods but I either end up with errors or a blank report.

So how can I just add values to the report?

by (100 points)
0

I finally got it to populate some data with this

$OmitList = 'Authenticated Users', 'Certificate Service DCOM Access', 'Domain Users', 'Everyone', 'Medium Plus Mandatory Level', 'Pre-Windows 2000 Compatible Access', 'Service asserted identity', 'This Organization', 'Users'
$Username = $Context.GetParameterValue('param-User')
$IncludeDefault = $Context.GetParameterValue('param-IncludeDefault')
$GroupList = Get-ADAccountAuthorizationGroup $Username | Sort-Object SamAccountName
#if (-not $IncludeDefault) {
    $GroupList = $GroupList | Where-Object { $_.SamAccountName -notin $OmitList }
#}
$objectList = $GroupList | ForEach-Object { Get-ADGroup $_.SamAccountName -Properties Description | Select-Object SamAccountName, Description, DistinguishedName }

foreach ($obj in $objectList) {
    $item = $Context.BindToObjectByDN($obj.DistinguishedName)
    $Context.Items.Add($item)
}

but is this really the best way to do this?

1 Answer

0 votes
by (288k points)

Hello,

Have a look at the following SDK article: https://www.adaxes.com/sdk/GeneratingReports. If you still struggle to update your script accordingly, please, describe the desired behavior in all the possible details with live examples. Also, specify what data should be included into the report and what should be selected for its generation.

Related questions

0 votes
1 answer

Hi, I'm currently facing a problem where I want to set up a powershell script that should report all accounts (enabled, disabled, expired) matching a specific employeeType ... something else, just the plain Info Can you help me with this? kind regards Ingemar

asked Sep 4, 2015 by ijacob (960 points)
0 votes
1 answer

I am working on creating a report which will pull data from O365 using PowerShell (data I am looking for is not available natively in ADAxes from what I can see), ... create the columns, and also to populate them with the attributes collected in the script.

asked Nov 4, 2022 by aweight (60 points)
0 votes
1 answer

Hi, would it be possible to script a workstation in AD and also directly from our local SCCM environment ?

asked Oct 28 by ddesmedt (40 points)
0 votes
1 answer

I've got the following script as part of a larger piece where param-members is an AD Object picker list seperated by a ' ; ' currently: New-DistributionGroup -Name ... or convert that to username but I'm struggling to achieve that with multiple Users selected

asked Jan 27, 2020 by richarddewis (260 points)
0 votes
0 answers

Hello, Please advise how to extract objects from two locations to create a report I am thinking something like SQL join operation Thank you.

asked Apr 4, 2023 by hhsmith (100 points)
3,541 questions
3,232 answers
8,225 comments
547,802 users