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()
}