<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Help with ISE 3.2 API powershell scripting in Network Access Control</title>
    <link>https://community.cisco.com/t5/network-access-control/help-with-ise-3-2-api-powershell-scripting/m-p/5256637#M594761</link>
    <description>&lt;P&gt;Hi guys.&lt;/P&gt;&lt;P&gt;New to this API call scripting malarky and need some assistance..&amp;nbsp; Basically im trying to change the access code on an ISE 3.2 guest portal.&amp;nbsp; &amp;nbsp;I can pull the necesary varibles with the script below,&amp;nbsp; look at them,&amp;nbsp; convernt them to json etc, but as soon as I go to change them back I get a 400 error..&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Im sure its something insanely basic so if someone can tell me where I am going wrong I would be greatful &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Script below:&lt;/P&gt;&lt;P&gt;$ISEServer = "&lt;A href="https://fqdn.of.server" target="_blank" rel="noopener"&gt;https://fqdn.of.server&lt;/A&gt;"&lt;BR /&gt;$Username = "ERSUser"&lt;BR /&gt;$Password = "XXXXXX"&lt;BR /&gt;$PortalID = "04f0e934-8d39-471d-bbb0-d24505e995e9"&lt;BR /&gt;$NewAccessCode = "NewPassword"&lt;/P&gt;&lt;P&gt;# Encode Credentials for Basic Authentication&lt;BR /&gt;$AuthHeader = @{&lt;BR /&gt;Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$Username`:$Password"))&lt;BR /&gt;"Content-Type" = "application/json"&lt;BR /&gt;Accept = "application/json"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# Get the existing portal configuration&lt;BR /&gt;$GetPortalUrl = "$ISEServer/ers/config/portal/$PortalID"&lt;BR /&gt;$CurrentPortal = Invoke-RestMethod -Uri $GetPortalUrl -Headers $AuthHeader -Method Get&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;$CurrentPortal.ERSPortal.aupPageAccessCode | Write-Output&lt;BR /&gt;$CurrentPortal.ERSPortal.aupPageAccessCode = $NewAccessCode&lt;BR /&gt;$CurrentPortal.ERSPortal.aupPageAccessCode | Write-Output&lt;/P&gt;&lt;P&gt;$CurrentPortal | Convertto-Json&lt;/P&gt;&lt;P&gt;$UpdatedPortalJson = $CurrentPortal | Convertto-Json&lt;/P&gt;&lt;P&gt;$Response = Invoke-RestMethod -Uri $GetPortalUrl -Headers $AuthHeader -Method Put -Body $UpdatedPortalJson&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 04 Feb 2025 16:29:49 GMT</pubDate>
    <dc:creator>James Vale</dc:creator>
    <dc:date>2025-02-04T16:29:49Z</dc:date>
    <item>
      <title>Help with ISE 3.2 API powershell scripting</title>
      <link>https://community.cisco.com/t5/network-access-control/help-with-ise-3-2-api-powershell-scripting/m-p/5256637#M594761</link>
      <description>&lt;P&gt;Hi guys.&lt;/P&gt;&lt;P&gt;New to this API call scripting malarky and need some assistance..&amp;nbsp; Basically im trying to change the access code on an ISE 3.2 guest portal.&amp;nbsp; &amp;nbsp;I can pull the necesary varibles with the script below,&amp;nbsp; look at them,&amp;nbsp; convernt them to json etc, but as soon as I go to change them back I get a 400 error..&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Im sure its something insanely basic so if someone can tell me where I am going wrong I would be greatful &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Script below:&lt;/P&gt;&lt;P&gt;$ISEServer = "&lt;A href="https://fqdn.of.server" target="_blank" rel="noopener"&gt;https://fqdn.of.server&lt;/A&gt;"&lt;BR /&gt;$Username = "ERSUser"&lt;BR /&gt;$Password = "XXXXXX"&lt;BR /&gt;$PortalID = "04f0e934-8d39-471d-bbb0-d24505e995e9"&lt;BR /&gt;$NewAccessCode = "NewPassword"&lt;/P&gt;&lt;P&gt;# Encode Credentials for Basic Authentication&lt;BR /&gt;$AuthHeader = @{&lt;BR /&gt;Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$Username`:$Password"))&lt;BR /&gt;"Content-Type" = "application/json"&lt;BR /&gt;Accept = "application/json"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;# Get the existing portal configuration&lt;BR /&gt;$GetPortalUrl = "$ISEServer/ers/config/portal/$PortalID"&lt;BR /&gt;$CurrentPortal = Invoke-RestMethod -Uri $GetPortalUrl -Headers $AuthHeader -Method Get&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;$CurrentPortal.ERSPortal.aupPageAccessCode | Write-Output&lt;BR /&gt;$CurrentPortal.ERSPortal.aupPageAccessCode = $NewAccessCode&lt;BR /&gt;$CurrentPortal.ERSPortal.aupPageAccessCode | Write-Output&lt;/P&gt;&lt;P&gt;$CurrentPortal | Convertto-Json&lt;/P&gt;&lt;P&gt;$UpdatedPortalJson = $CurrentPortal | Convertto-Json&lt;/P&gt;&lt;P&gt;$Response = Invoke-RestMethod -Uri $GetPortalUrl -Headers $AuthHeader -Method Put -Body $UpdatedPortalJson&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Feb 2025 16:29:49 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/help-with-ise-3-2-api-powershell-scripting/m-p/5256637#M594761</guid>
      <dc:creator>James Vale</dc:creator>
      <dc:date>2025-02-04T16:29:49Z</dc:date>
    </item>
    <item>
      <title>Re: Help with ISE 3.2 API powershell scripting</title>
      <link>https://community.cisco.com/t5/network-access-control/help-with-ise-3-2-api-powershell-scripting/m-p/5257287#M594782</link>
      <description>&lt;P&gt;I'm not a Powershell coder myself, but I have dabbled a bit with Postman, curl and some python libraries.&amp;nbsp; I would look for things like:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Does your python request enforce a certificate check when speaking with the ISE server?&amp;nbsp; Ideally, you should provide the CA chain to your script to validate/establish that trust. Failing that, enable a switch/parameter to force the security check off.&lt;/LI&gt;
&lt;LI&gt;Are you pointing the URL to the PAN on port 443?&lt;/LI&gt;
&lt;LI&gt;Test the concept in curl first (the python script has too many moving parts) - some calls must be made to the MNT, and not the PAN&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;e.g. when using curl, I can cheat by using the '--insecure' parameter to ignore cert checks&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;curl --insecure --netrc-file ~/.secrets/.netrc -X 'GET' 'https://rnolabise01.rnlab.local:443/ers/config/portala486c6ef-6c77-4bc1-bf6d-4e479b3aeae88'  -H 'accept: application/json'


{
  "ERSPortal" : {
    "id" : "a486c6ef-6c77-4bc1-bf6d-4e479b3aeae8",
    "name" : "ISE Portal (default)",
    "description" : "Ise Portal for saml based feature purpose",
    "portalType" : "GUEST",
    "link" : {
      "rel" : "self",
      "href" : "https://rnolabise01.rnlab.local/ers/config/portal/a486c6ef-6c77-4bc1-bf6d-4e479b3aeae8",
      "type" : "application/json"
    }
  }
}

&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 21:08:09 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/help-with-ise-3-2-api-powershell-scripting/m-p/5257287#M594782</guid>
      <dc:creator>Arne Bier</dc:creator>
      <dc:date>2025-02-05T21:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: Help with ISE 3.2 API powershell scripting</title>
      <link>https://community.cisco.com/t5/network-access-control/help-with-ise-3-2-api-powershell-scripting/m-p/5257288#M594783</link>
      <description>&lt;P&gt;Thanks.&lt;/P&gt;&lt;P&gt;I found the problem in the end..&amp;nbsp; &amp;nbsp;Slight script modifications converting BASH to Powershell via ChatGPT but the main cause was the fact that /ers/config/portal does not permit PUT or PATCH.&amp;nbsp; &amp;nbsp;I had to use /ers/config/hotspotportal instead.&lt;/P&gt;&lt;P&gt;Code below for anyone else looking to achieve the same using Powershell&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;# Variables
$NewAccessCode = "XXXX"						#Guest Portal Access Password Change this Weekly

$ISEServer = "XXXX"						#ISE Server URL
$Username = "ERSAdmin"						#ERS User
$Password = "XXXXXXXXXXX"					#ERS User Password
$PortalID = "XXXXXXXXDXXXXXXXXXXXXXXXXXXXXXXX"  		#ISE Portal ID


# Encode Credentials for Basic Authentication
$AuthHeader = @{
    Authorization = "Basic " + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes("$Username`:$Password"))
    "Content-Type" = "application/json"
    Accept = "application/json"
}

$url = "https://$ISEServer/ers/config/hotspotportal/$PortalID"	#ISE API Portal URL 


$body = @{
    "HotspotPortal" = @{
        "settings" = @{
            "aupSettings" = @{
                "accessCode" = "NewPassword"
            }
        }
    }
} | ConvertTo-Json -Depth 10


try {
    Invoke-RestMethod -Uri $url -Method Patch -Headers $AuthHeader -Body $body
    Write-Output "Hotspot portal access code updated successfully."
} catch {
    Write-Output "Error Response (PUT Request):"
    Write-Output $_.Exception.Message
    Write-Output "Press Enter to exit..."
    Read-Host
    break
}

&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 21:13:32 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/help-with-ise-3-2-api-powershell-scripting/m-p/5257288#M594783</guid>
      <dc:creator>James Vale</dc:creator>
      <dc:date>2025-02-05T21:13:32Z</dc:date>
    </item>
    <item>
      <title>Re: Help with ISE 3.2 API powershell scripting</title>
      <link>https://community.cisco.com/t5/network-access-control/help-with-ise-3-2-api-powershell-scripting/m-p/5257299#M594785</link>
      <description>&lt;P&gt;The API endpoint you are using '/ers/config/portal' only supports GET methods as per the documentation. You cannot use this API endpoint to make changes.&lt;BR /&gt;&lt;A href="https://developer.cisco.com/docs/identity-services-engine/latest/portal/" target="_blank"&gt;https://developer.cisco.com/docs/identity-services-engine/latest/portal/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;To make updates to an existing portal, try using the PUT method with the '/ers/config/sponsoredguestportal/{portal-id}' API endpoint.&lt;BR /&gt;&lt;A href="https://developer.cisco.com/docs/identity-services-engine/latest/sponsoredguestportal/" target="_blank"&gt;https://developer.cisco.com/docs/identity-services-engine/latest/sponsoredguestportal/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 Feb 2025 21:43:13 GMT</pubDate>
      <guid>https://community.cisco.com/t5/network-access-control/help-with-ise-3-2-api-powershell-scripting/m-p/5257299#M594785</guid>
      <dc:creator>Greg Gibbs</dc:creator>
      <dc:date>2025-02-05T21:43:13Z</dc:date>
    </item>
  </channel>
</rss>

