- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
Our community just got stronger! Explore new identity security resources, connect with experts, and discover more ways to learn and collaborate.
08-28-2019 05:25 AM
I tried to connect to our PVWA with PowerShell's 'Invoke-WebRequest'.
$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].FieldsThe result I get for the variabl $UrlResponse is:
StatusCode : 200
StatusDescription : OK
Content : {...}
RawContent : HTTP/1.1 200 OK
Pragma: ...
X-UA-Compatible: ...
X-XSS-Protection: ..; mode=...
X-Content-Type-Options: ....
X-FRAME-Options: ....
Access-Control-Expose-Headers: ...
Headers : {[]}
RawContentLength : ...
I saw the material for Postman but I was wondering whether this approach is feasible as well.
08-28-2019 07:35 AM
PowerShell Invoke-WebRequest (or Invoke-RestMethod) can certainly be used.
You should however refer to the API documentation; as far as I can tell, the code you have posted does not interact with the API.
An example authentication request to the (classic) API could look like this:
$url = "https://PVWA/PasswordVault/WebServices/auth/Cyberark/CyberArkAuthenticationService.svc/Logon"
$body = New-Object -Property @{"username" = "YourUser"; "password" = "SomePassword" } -TypeName psobject | ConvertTo-Json
Invoke-RestMethod -Uri $url -Method POST -ContentType "application/json" -Body $bodyOther API endpoints for the version 10 API are available (dependent on your PAS version).
This module may save you some time: https://www.powershellgallery.com/packages/psPAS/
08-28-2019 07:35 AM
PowerShell Invoke-WebRequest (or Invoke-RestMethod) can certainly be used.
You should however refer to the API documentation; as far as I can tell, the code you have posted does not interact with the API.
An example authentication request to the (classic) API could look like this:
$url = "https://PVWA/PasswordVault/WebServices/auth/Cyberark/CyberArkAuthenticationService.svc/Logon"
$body = New-Object -Property @{"username" = "YourUser"; "password" = "SomePassword" } -TypeName psobject | ConvertTo-Json
Invoke-RestMethod -Uri $url -Method POST -ContentType "application/json" -Body $bodyOther API endpoints for the version 10 API are available (dependent on your PAS version).
This module may save you some time: https://www.powershellgallery.com/packages/psPAS/
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!

