<?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: Can one use the REST API with PowerShell's 'Invoke-WebRequest'? in PAM Self-Hosted Discussions</title>
    <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/can-one-use-the-rest-api-with-powershell-s-invoke-webrequest/m-p/1397844#M77020</link>
    <description>&lt;P&gt;PowerShell Invoke-WebRequest (or Invoke-RestMethod) can certainly be used.&lt;/P&gt;&lt;P&gt;You should however refer to the &lt;A alt="https://docs.cyberark.com/Product-Doc/OnlineHelp/PAS/Latest/en/Content/WebServices/API%20Commands.htm" href="https://docs.cyberark.com/Product-Doc/OnlineHelp/PAS/Latest/en/Content/WebServices/API%20Commands.htm" target="_blank"&gt;API documentation&lt;/A&gt;; as far as I can tell, the  code you have posted does not interact with the API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example authentication request to the (classic) API could look like this:&lt;/P&gt;&lt;CODE&gt;$url = "https://PVWA/PasswordVault/WebServices/auth/Cyberark/CyberArkAuthenticationService.svc/Logon"
$body = New-Object -Property @{"username" = "YourUser"; "password" = "SomePassword" } -TypeName psobject | ConvertTo-Json
&amp;nbsp;
Invoke-RestMethod -Uri $url -Method POST -ContentType "application/json" -Body $body&lt;/CODE&gt;&lt;P&gt;Other API endpoints for the version 10 API are available (dependent on your PAS version).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This module may save you some time: &lt;A alt="https://www.powershellgallery.com/packages/psPAS/" href="https://www.powershellgallery.com/packages/psPAS/" target="_blank"&gt;https://www.powershellgallery.com/packages/psPAS/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 28 Aug 2019 14:35:22 GMT</pubDate>
    <dc:creator>CyberArkAlumni</dc:creator>
    <dc:date>2019-08-28T14:35:22Z</dc:date>
    <item>
      <title>Can one use the REST API with PowerShell's 'Invoke-WebRequest'?</title>
      <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/can-one-use-the-rest-api-with-powershell-s-invoke-webrequest/m-p/1397843#M77019</link>
      <description>&lt;P&gt;I tried to connect to our PVWA with PowerShell's 'Invoke-WebRequest'. ​&lt;/P&gt;&lt;CODE&gt;$CA = 'https://pvwaLink.com/PasswordVault/'
 
$response = Invoke-WebRequest -Uri $CA -SessionVariable UrlSession
# Filling in the name and password to login (not the real credentials)
$response.Forms[0].Fields["pvBody_PageTemplate_innerHolder_ctrlLogon_txtUsername"]="admin"
$response.Forms[0].Fields["pvBody_PageTemplate_innerHolder_ctrlLogon_txtPassword"]="admin"
 
#Authenticate
$UrlResponse = Invoke-WebRequest -Uri ($CA + $response.Forms[0].Action) -WebSession $UrlSession -Method POST -Body $response.Forms[0].Fields&lt;/CODE&gt;&lt;P&gt;The result I get for the variabl $UrlResponse is:&lt;/P&gt;&lt;P&gt;StatusCode : 200&lt;/P&gt;&lt;P&gt;StatusDescription : OK&lt;/P&gt;&lt;P&gt;Content : {...}&lt;/P&gt;&lt;P&gt;RawContent : HTTP/1.1 200 OK&lt;/P&gt;&lt;P&gt;Pragma: ...&lt;/P&gt;&lt;P&gt;X-UA-Compatible: ...&lt;/P&gt;&lt;P&gt;X-XSS-Protection: ..; mode=...&lt;/P&gt;&lt;P&gt;X-Content-Type-Options: ....&lt;/P&gt;&lt;P&gt;X-FRAME-Options: ....&lt;/P&gt;&lt;P&gt;Access-Control-Expose-Headers: ...&lt;/P&gt;&lt;P&gt;Headers : {[]}&lt;/P&gt;&lt;P&gt;RawContentLength : ...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I saw the material for Postman but I was wondering whether this approach is feasible as well.&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 12:25:01 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/can-one-use-the-rest-api-with-powershell-s-invoke-webrequest/m-p/1397843#M77019</guid>
      <dc:creator>CyberArkAlumni</dc:creator>
      <dc:date>2019-08-28T12:25:01Z</dc:date>
    </item>
    <item>
      <title>Re: Can one use the REST API with PowerShell's 'Invoke-WebRequest'?</title>
      <link>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/can-one-use-the-rest-api-with-powershell-s-invoke-webrequest/m-p/1397844#M77020</link>
      <description>&lt;P&gt;PowerShell Invoke-WebRequest (or Invoke-RestMethod) can certainly be used.&lt;/P&gt;&lt;P&gt;You should however refer to the &lt;A alt="https://docs.cyberark.com/Product-Doc/OnlineHelp/PAS/Latest/en/Content/WebServices/API%20Commands.htm" href="https://docs.cyberark.com/Product-Doc/OnlineHelp/PAS/Latest/en/Content/WebServices/API%20Commands.htm" target="_blank"&gt;API documentation&lt;/A&gt;; as far as I can tell, the  code you have posted does not interact with the API.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;An example authentication request to the (classic) API could look like this:&lt;/P&gt;&lt;CODE&gt;$url = "https://PVWA/PasswordVault/WebServices/auth/Cyberark/CyberArkAuthenticationService.svc/Logon"
$body = New-Object -Property @{"username" = "YourUser"; "password" = "SomePassword" } -TypeName psobject | ConvertTo-Json
&amp;nbsp;
Invoke-RestMethod -Uri $url -Method POST -ContentType "application/json" -Body $body&lt;/CODE&gt;&lt;P&gt;Other API endpoints for the version 10 API are available (dependent on your PAS version).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This module may save you some time: &lt;A alt="https://www.powershellgallery.com/packages/psPAS/" href="https://www.powershellgallery.com/packages/psPAS/" target="_blank"&gt;https://www.powershellgallery.com/packages/psPAS/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Aug 2019 14:35:22 GMT</pubDate>
      <guid>https://live.paloaltonetworks.com/t5/pam-self-hosted-discussions/can-one-use-the-rest-api-with-powershell-s-invoke-webrequest/m-p/1397844#M77020</guid>
      <dc:creator>CyberArkAlumni</dc:creator>
      <dc:date>2019-08-28T14:35:22Z</dc:date>
    </item>
  </channel>
</rss>

