I am trying to get information from a built in report, and add it to a custom attribute. I need to get the IP address in the built in report "Dial-in and VPN settings" and add it to a custom attribute for each user.

I tried modifying this script to get there: https://www.adaxes.com/script-repository/update-boolean-attribute-with-password-self-service-enrollment-status-s680.htm

I think the main issues are:

  • The well known container path. I can't figure out the path for Reports > All Reports > Users > Dial-in and VPN Settings
  • my ADM_PSREPORTTYPE is also probably wrong
  • And at the very end, I try to get $userstaticIP from the "Dial-In and VPN settings" report which contains the info I need.

Here is the script:

$propertyName = "adm-CustomAttributeBinary1" # TODO: modify me

# Bind to the 'Dial-in and VPN settings' container
$DialInReportPath = $Context.GetWellKnownContainerPath("Report")
$DialIn = $Context.BindToObject($DialInReportPath)

# Get the Dial-in and VPN settings report
$reportIsBeingGenerated = $True
do
{
    try
    {
        $report = $DialIn.GetReport("ADM_PSSREPORTTYPE_DialinandVPNsettings")
    }
    catch [System.Runtime.InteropServices.COMException]
    {
        if ($_.Exception.ErrorCode -eq "-2147024875")
        {
            # Report is being generated. Wait 10 seconds
            Start-Sleep -Seconds 10
            continue
        }
        else
        {
            $reportIsBeingGenerated = $False
            $Context.LogMessage($_.Exception.Message, "Error")
            return
        }
    }

    if ($report.GenerateDate -lt [System.Datetime]::UtcNow.AddHours(-1))
    {
        $DialIn.ResetReportCache("ADM_PSSREPORTTYPE_DialinandVPNsettings")
    }
    else
    {
        $reportIsBeingGenerated = $False
    }
}
while ($reportIsBeingGenerated)

$records = $report.Records
for ($i = 0; $i -lt $records.Count; $i++)
{
    $record = $records.GetRecord($i)

    # Get user information
    $userPath = $NULL
    $userDisplayName = $NULL
    $userstaticIP = $NULL
    $userInfo = $record.GetUserInfo([ref]$userPath, [ref]$userDisplayName, [ref]$userstaticIP)

    # Update user
    $user = $Context.BindToObject($userPath)
    $user.Put($propertyName, $userstaticIP)
    $user.SetInfo()
}
ago by (350 points)

1 Answer

ago by (307k points)
0 votes

Hello,

Unfortunately, the approach you are using is overcomplicated and hardly usable. As an option, you can create a scheduled task configured for the User object type. For each user the task will execute a PowerShell script that will obtain values just like the report script and save them to Adaxes custom attributes. The following article should be helpful in writing the script: https://adaxes.com/sdk/ServerSideScripting.

Related questions

Hi, when I enable a license for Exchange Online for a user I get the following warning: Here are the current settings for creating a remote ... : InvalidOperation: (:) [], RuntimeException     + FullyQualifiedErrorId : PropertyAssignmentException

asked Nov 18 by Allister (90 points)
0 votes
1 answer

When tryin to add a new server to a current shared configuration, i get a "Failed to Connect to Service Configuration Server", Username or Password wrong. I checked the ... with domain\username and username@domain, both with the same error. Any ideas on that?

asked Oct 14 by roppiffm (170 points)
0 votes
1 answer

Recently we started getting this error in Adaxes Some fields couldn't be loaded. Failed to get the mailbox usage information. Failed to commit the change on object " ... are correct but the issue persists. This is occuring with Exchange Online only:

asked May 21 by curtisa (350 points)
0 votes
1 answer

When attempting to modify a shared mailbox that is in 365 but anchored in on premise AD, I am receiving the following error when trying to add a regular user to ... Builtin Administrators group anywhere, I'm not sure where Adaxes is picking this up from.

asked Jan 17 by curtisa (350 points)
0 votes
1 answer

Hi I've created a new adaxes configuration and limited access to do things based on the 'actions' section: only create, modify, delete contacts are available. Added myself to ... since updating to version 3.16.21408.0. How can I resolve this error? Thanks

asked Oct 4, 2023 by cheezoid (20 points)
0 votes
1 answer