<?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 Re: PowerShell SAML Rest API auth in Endpoint Privilege Manager (EPM) Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334388#M2097</link>
    <description>&lt;P&gt;Thank you @Derek Hartman​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me validate.&lt;/P&gt;</description>
    <pubDate>Thu, 31 Aug 2023 15:07:29 GMT</pubDate>
    <dc:creator>by</dc:creator>
    <dc:date>2023-08-31T15:07:29Z</dc:date>
    <item>
      <title>PowerShell SAML Rest API auth</title>
      <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334383#M2092</link>
      <description>&lt;P&gt;Ok, so I am trying to follow this doc. &lt;/P&gt;&lt;P&gt;https://docs.cyberark.com/EPM/Latest/en/Content/WebServices/SAMLAuthentication.htm&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;CODE&gt;Import-Module PS-SAML-Interactive
&amp;nbsp;
$LoginURL = "Okta embedded app link"
&amp;nbsp;
$Value = New-SAMLInteractive -LoginIDP $LoginURL -Verbose
&amp;nbsp;
$Header = @{
    'Content-Type'  = 'application/x-www-form-urlencoded';
}
&amp;nbsp;
$Body = @{
    'Key'   = 'SAMLResponse';
    'Value' = "$Value";
}
&amp;nbsp;
$JsonBody =  ConvertTo-JSON $Body
&amp;nbsp;
Invoke-RestMethod -Uri "https://login.epm.cyberark.com/SAML/Logon" -Method Post -Headers $Header -Body $JsonBody&lt;/CODE&gt;&lt;P&gt;This is the code I am trying to use but it just keeps failing and I have no idea why. I found PS-SAML-Interactive module from a post in the community for a different cyberark product but it doesn't seem to work. I even tried manually grabbing the token from SAML tracer and that doesn't work either. &lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does anyone have a working PowerShell script for SAML auth?&lt;/P&gt;</description>
      <pubDate>Wed, 23 Aug 2023 16:04:04 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334383#M2092</guid>
      <dc:creator>DHartman</dc:creator>
      <dc:date>2023-08-23T16:04:04Z</dc:date>
    </item>
    <item>
      <title>Re: PowerShell SAML Rest API auth</title>
      <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334384#M2093</link>
      <description>&lt;CODE&gt;function New-SAMLInteractive{
&amp;nbsp;
    [CmdletBinding()]
	param(
		[Parameter(Mandatory=$true)]
		[string] $LoginIDP
	)
&amp;nbsp;
    Begin{
&amp;nbsp;
        $RegEx = '(?i)name="SAMLResponse"(?: type="hidden")? value=\"(.*?)\"(?:.*)?\/&amp;gt;'
&amp;nbsp;
        Add-Type -AssemblyName System.Windows.Forms 
        Add-Type -AssemblyName System.Web
&amp;nbsp;
    }
&amp;nbsp;
    Process{
&amp;nbsp;
        # create window for embedded browser
        $form = New-Object Windows.Forms.Form
        $form.StartPosition = [System.Windows.Forms.FormStartPosition]::CenterScreen;
        $form.Width = 640
        $form.Height = 700
        $form.showIcon = $false
        $form.TopMost = $true
    
        $web = New-Object Windows.Forms.WebBrowser
        $web.Size = $form.ClientSize
        $web.Anchor = "Left,Top,Right,Bottom"
        $web.ScriptErrorsSuppressed = $true
&amp;nbsp;
        $form.Controls.Add($web)
&amp;nbsp;
        $web.Navigate($LoginIDP)
        
        $web.add_Navigating({
    
            if ($web.DocumentText -match "SAMLResponse"){
&amp;nbsp;
                $_.cancel = $true
&amp;nbsp;
                if ($web.DocumentText -match $RegEx){
            
                    $form.Close()
                    $Script:SAMLResponse = $(($Matches[1] -replace '&amp;amp;#x2b;', '+') -replace '&amp;amp;#x3d;', '=')
                    
&amp;nbsp;
                }
&amp;nbsp;
            }
&amp;nbsp;
        })
    
        # show browser window, waits for window to close
        if([system.windows.forms.application]::run($form) -ne "OK") {
            
            if ($null -ne $Script:SAMLResponse){
&amp;nbsp;
                Write-Output $Script:SAMLResponse
                $form.Close()
                Remove-Variable -Name SAMLResponse -Scope Script -ErrorAction SilentlyContinue
&amp;nbsp;
            }
            Else{
            
                throw "SAMLResponse not matched"
            
            }
    
        }
    }
&amp;nbsp;
    End{
        
        $form.Dispose()
        
    }
&amp;nbsp;
}
#Logon
$SAMlResponse=New-SAMLInteractive -LoginIDP 'IDP_URL_HERE'
&amp;nbsp;
&amp;nbsp;
&amp;nbsp;
$headers = New-Object "System.Collections.Generic.Dictionary[[String],[String]]"
$headers.Add("Content-Type", "application/json")
&amp;nbsp;
&amp;nbsp;
$url = "https://PVWA.COM/PasswordVault/api/auth/saml/logon"
&amp;nbsp;
$body = @{
&amp;nbsp;
concurrentSession='true'
&amp;nbsp;
apiUse='true'
&amp;nbsp;
SAMLResponse=$SAMlResponse
&amp;nbsp;
}
&amp;nbsp;
$token = Invoke-RestMethod -Uri $url -Method Post -body $body -ContentType 'application/x-www-form-urlencoded'
&amp;nbsp;
$headers.Add("Authorization", "$token")
#Logon End&lt;/CODE&gt;&lt;P&gt;Credits for the original PS Script: https://github.com/allynl93/getSAMLResponse-Interactive&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 13:29:37 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334384#M2093</guid>
      <dc:creator>Trevor_B</dc:creator>
      <dc:date>2023-08-24T13:29:37Z</dc:date>
    </item>
    <item>
      <title>Re: PowerShell SAML Rest API auth</title>
      <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334385#M2094</link>
      <description>&lt;P&gt;Your $body parameter is what fixed it for me. I just replaced that and removed the convert json and it is now working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You're awesome thank you very much for the help!!!&lt;/P&gt;</description>
      <pubDate>Thu, 24 Aug 2023 13:51:46 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334385#M2094</guid>
      <dc:creator>DHartman</dc:creator>
      <dc:date>2023-08-24T13:51:46Z</dc:date>
    </item>
    <item>
      <title>Re: PowerShell SAML Rest API auth</title>
      <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334386#M2095</link>
      <description>&lt;P&gt;Hi @Derek Hartman​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please share your powershell code(after masking the environment URLs) using which you are able to authenticate to CyberArk via SAML? I am unable to do it getting error "Sorry, but we’re having trouble signing you in.&lt;/P&gt;&lt;P&gt;AADSTS750054: SAMLRequest or SAMLResponse must be present as query string parameters in HTTP request for SAML Redirect binding"&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 10:09:41 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334386#M2095</guid>
      <dc:creator>by</dc:creator>
      <dc:date>2023-08-28T10:09:41Z</dc:date>
    </item>
    <item>
      <title>Re: PowerShell SAML Rest API auth</title>
      <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334387#M2096</link>
      <description>&lt;P&gt;@Sabyasachi Patnaik​&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sure, here is my code. &lt;/P&gt;&lt;CODE&gt;Import-Module PS-SAML-Interactive
&amp;nbsp;
$LoginURL = "Okta embedded app link"
&amp;nbsp;
$Value = New-SAMLInteractive -LoginIDP $LoginURL -Verbose
&amp;nbsp;
$Header = @{
    'Content-Type'  = 'application/x-www-form-urlencoded';
}
&amp;nbsp;
$Body = @{ 
    concurrentSession='true' 
    apiUse='true' 
    SAMLResponse=$Value 
}
&amp;nbsp;
Invoke-RestMethod -Uri "https://login.epm.cyberark.com/SAML/Logon" -Method Post -Headers $Header -Body $Body&lt;/CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 14:00:38 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334387#M2096</guid>
      <dc:creator>DHartman</dc:creator>
      <dc:date>2023-08-28T14:00:38Z</dc:date>
    </item>
    <item>
      <title>Re: PowerShell SAML Rest API auth</title>
      <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334388#M2097</link>
      <description>&lt;P&gt;Thank you @Derek Hartman​&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me validate.&lt;/P&gt;</description>
      <pubDate>Thu, 31 Aug 2023 15:07:29 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334388#M2097</guid>
      <dc:creator>by</dc:creator>
      <dc:date>2023-08-31T15:07:29Z</dc:date>
    </item>
    <item>
      <title>Re: PowerShell SAML Rest API auth</title>
      <link>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334389#M2098</link>
      <description>&lt;P&gt;In your case, you did for IDP initiated not for SP Initiated right?&lt;/P&gt;</description>
      <pubDate>Tue, 08 Sep 2026 16:08:42 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/endpoint-privilege-manager-epm/powershell-saml-rest-api-auth/m-p/1334389#M2098</guid>
      <dc:creator>Sanzu</dc:creator>
      <dc:date>2026-09-08T16:08:42Z</dc:date>
    </item>
  </channel>
</rss>

