# Get Access Request Comments in Powershell script

**URL:** <https://developer.sailpoint.com/discuss/t/get-access-request-comments-in-powershell-script/75668>\
**Category:** SHF Discussion and Questions\
**Tags:** rules, sailpoint-identity-security\
**Created:** [August 7, 2024, 7:52am UTC](https://developer.sailpoint.com/discuss/t/get-access-request-comments-in-powershell-script/75668 "2024-08-07T07:52:55Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikhlesh21](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/nikhlesh21/32/11800_2.png) [@nikhlesh21](https://developer.sailpoint.com/discuss/u/nikhlesh21)\
**Post date:** [August 7, 2024, 7:52am UTC](https://developer.sailpoint.com/discuss/t/get-access-request-comments-in-powershell-script/75668/1 "2024-08-07T07:52:55Z")

</div>

Hello,

I am using After Modify Rule to trigger the Powershell script. After requesting Entitlement access, After Modify rule is triggered which contains the Requestor Comments (as per attached logs), now I need to get these comments in Powershell script.

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/3/3b2b661ddb4b108ee74d3c7a707fbe27707f43ba.png)

Can anyone help on this?

Thanks.

---

<div class="post-metadata">

**Author:** ![jesvin90](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/jesvin90/32/5301_2.png) [@jesvin90](https://developer.sailpoint.com/discuss/u/jesvin90)\
**Post date:** [August 7, 2024, 1:42pm UTC](https://developer.sailpoint.com/discuss/t/get-access-request-comments-in-powershell-script/75668/3 "2024-08-07T13:42:36Z")

</div>

Hi @nikhlesh21,

Try something as below :

```auto
$sReader = New-Object System.IO.StringReader([System.String]$requestString);
$xmlReader = [System.xml.XmlTextReader]([sailpoint.utils.xml.XmlUtil]::getReader($sReader));
$requestObject = New-Object Sailpoint.Utils.objects.AccountRequest($xmlReader);
$attributesMap = $requestObject.Attributes

```

You can then write the value of $attributesMap to a log file to see if the comments value exist in the output.

If yes, you can call it. As I can’t see your full log file, it could be something as below or make required adjustments

`$attributesMap.comments` OR `$attributesMap.comments.value`

OR

`$attributesMap.IdnAccessRequestAttributes.comments` OR `$attributesMap.IdnAccessRequestAttributes.comments.value`

---

<div class="post-metadata">

**Author:** ![nikhlesh21](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/nikhlesh21/32/11800_2.png) [@nikhlesh21](https://developer.sailpoint.com/discuss/u/nikhlesh21)\
**Post date:** [August 9, 2024, 6:06am UTC](https://developer.sailpoint.com/discuss/t/get-access-request-comments-in-powershell-script/75668/4 "2024-08-09T06:06:30Z")

</div>

HI @jesvin90,

Thanks for the suggestion but it did not work out. I have attached the complete log of After modify script, if you can suggest something else.

 ![image](https://global.discourse-cdn.com/sailpoint/original/2X/a/aac143e57e7fb2274b2842bf2aa5542b027b58e2.png)

---

<div class="post-metadata">

**Author:** ![jesvin90](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/jesvin90/32/5301_2.png) [@jesvin90](https://developer.sailpoint.com/discuss/u/jesvin90)\
**Post date:** [August 9, 2024, 8:12am UTC](https://developer.sailpoint.com/discuss/t/get-access-request-comments-in-powershell-script/75668/5 "2024-08-09T08:12:51Z")

</div>

Try this:

```auto
$sReader = New-Object System.IO.StringReader([System.String]$requestString);
$xmlReader = [System.xml.XmlTextReader]([sailpoint.utils.xml.XmlUtil]::getReader($sReader));
$requestObject = New-Object Sailpoint.Utils.objects.AccountRequest($xmlReader);
$comments = $requestObject.AttributeRequests.Attributes.comments

```

---

<div class="post-metadata">

**Author:** ![nikhlesh21](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/nikhlesh21/32/11800_2.png) [@nikhlesh21](https://developer.sailpoint.com/discuss/u/nikhlesh21)\
**Post date:** [August 9, 2024, 9:36am UTC](https://developer.sailpoint.com/discuss/t/get-access-request-comments-in-powershell-script/75668/6 "2024-08-09T09:36:55Z")

</div>

HI @jesvin90,

Yes, it worked. thank you for your help.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [October 8, 2024, 9:37am UTC](https://developer.sailpoint.com/discuss/t/get-access-request-comments-in-powershell-script/75668/7 "2024-10-08T09:37:43Z")

</div>

Closed on October 8, 2024, 9:37am UTC

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
