Retrieve the list of users from a policy
Information
You can download the script for retrieving the list of users from an Axidian policy from this link.
Prerequisites
- The Active Directory module for PowerShell installed on Windows Server.
- A working Axidian Access server.
- The user on whose behalf the script will be run must have the minimal global Inspector rights.
How the script works
The script exports the list of users from the specified policy in CSV format. The user attributes UserPrincipalName and displayName are exported.
- The script iterates over the policy identifiers from the array in the configuration file Config.ps1.
- Using the
/api/v5/policy/getmethod, information about the policy is requested. - From the scope property, information about the configured objects is requested using the
/api/v5/userCatalog/getObjectsmethod. - From the obtained objects, users are requested:
- Using the
Get-ADGroupcmdlet in thegetUsersCNfunction of the file Base/AdditionalFunctions/GetUsers.ps1 for an Active Directory group. - Using the
Get-ADUsercmdlet in thegetUsersOUfunction of the file Base/AdditionalFunctions/GetUsers.ps1 for an Active Directory organizational unit. - Using the
Get-ADUsercmdlet in thegetADUserfunction of the file Base/AdditionalFunctions/GetUsers.ps1 for an Active Directory user.
- Using the
- Using the
addDataForUserInPolicyReportCsvfunction of the file Scenarios/Reports/CsvReport.ps1, a table in CSV format is assembled.
Configuration
- In the file Config.ps1, in the
$serverUrlvariable, specify the address of the Axidian Access server in the formathttps://axidian.access.local/. - In the
$logServerUrlvariable, specify the address of the Log Server in the formathttps://axidian.access.local/. - In the
$policyIdsvariable, specify the identifier of the target policy in the format @('2fc7eeec-5adf-4a50-bad3-ba04585c76cd'). You can specify several separated by a comma @('2fc7eeec-5adf-4a50-bad3-ba04585c76cd','7436daa7-abf7-437b-991f-0e89cc9f1b9b').
Tip
You can find the policy identifier in the Management Console. Open the desired policy; the identifier is contained in the browser address bar in the policyId variable.
The file with the exported users is saved in the directory $ScriptDirectory\Reports\UserInPolicyReport. If you want to save the file in another location, specify the path in the $pathReportUserInPolicyReport variable in the file Config.ps1.
To run the script, execute the file Start.ps1 using PowerShell.