Hi, can someone please help me on one powershell api call. I am using one API Get-BetaPersonalAccessTokens to display existing personal access token created in Sailpoint IDN
Get-BetaPersonalAccessTokens
Name Value
---- -----
id xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
name PAT
scope {sp:scopes:all, sp:scopes:default}
created 1/20/2024 5:14:35 PM
owner {[id, xxxxxxxxxxxxxxxxxxxxxxxxxxx], [type, IDENTITY], [name, Jimmy]}
managed False
lastUsed 3/25/2024 1:27:19 PM
This API I am calling from one Powershell script :
When you convert complex or multivalued Objects to a string in PowerShell it will display as the Object’s Type instead of it’s content. I would first try removing the Out-String Pipe and change the Body Parameter from -Body $EmailBody to -Body "$EmailBody" . I’m assuming $EmailBody contains the $Result2 variable?
But even when using the ConvertTo commands you’ll see similar behavior. And Owner would capture all attributes so you may need to create a PSCustomObject to get the output looking the way you want. Just make sure anything you want treated a string that is not a string is encapsulated in quotes. So for Scopres you would write that as "$($Result2.scope)" to force it to a string in your Custom Object.
Hi Derek @dmbrown1386 ,
Thanks for your response. I tried suggestion provided by you but looks like I am doing some mistake. If its possible, could you please provide sample modified code as per my case, may be this will be helpful for many users for reference.
The reason this is occurring is because the value of the scope property is an array, which goes unhandled when converting to HTML without instructions to expand that array. Below is a quick script I threw together for you to handle this. Feel free to modify as you see fit. This will generate the HTML data for you. All Scopes will be joined together with a comma.