Hi, Can any one please help me on search query invoke example from Powershell sdk. For example, I have these two different search queries which I am using from Sailpoint admin console search page:
Example 1 - @accounts(source.name:ApplicationName) AND attributes.employeeStatus: "T"
Example 2 - attributes.sourceName:("SourceName1","SourceName2") AND created:[now-7d TO now] AND operation:Aggregate AND status:Failed
This same query I want to invoke from powershell and save the output in csv file.
Also, one more thing, when we use search query from Sailpoint console, we have an option to select required columns and sort it. Can we do similar kind of column filter and sort in powershell api call.
The script below includes an example on how to use your two queries in the PowerShell SDK. To get the json for the query, I just used the chrome browser to inspect the call in the UI and pulled out the search payload.
most of these column values in csv appear ok but for few its showing up as - System.Management.Automation.OrderedHashtable could you please suggest me how to handle this and how the proper value.
The issue here is that the ConvertTo-Csv cmdlet does not support nested objects. The CSV format is typically meant to be a flat file, and not for nested object values.
@tyler_mairose is correct and the Convert to CSV command can’t handle nested objects, you’ll get the Type of the object instead of the contents. Depending on your needs you can use JSON like he suggested, just be sure to use the Depth parameter, 10 is usually deep enough, but no risk of going higher that I’ve found.
@hranjan3, another options is run a Foreach loop through your Search results and create a PSCustomObject:
Accounts and Access are Arrays, so if you also want data from those lists it will be more involved. But for Attributes and Manager you can just create a line for the details you want in the Custom Object. Does that help?