How to upload files using REST and Powershell

How to upload files using REST and Powershell

95
Created On 11/10/26 10:56 AM - Last Modified 11/10/26 15:58 PM


Objective


To upload files in Powershell using CyberArk's REST API, the file must be converted to a Byte array.  This can be done in Powershell through the following commands



Procedure


$File_Path = "C:\path\to\file.zip"
$fileBytes = ([IO.File]::ReadAllBytes($File_Path))
$restBody = @{ ImportFile=$fileBytes } | ConvertTo-JSON
Invoke-RestMethod -method POST -URI "https://pvwa.server.com/passwordvaul/api/platforms/import" -ContentType "application/JSON" -header $token -body $restbody
 
 
PlatformID
----------
PlatformID_As_Defined_In_ZIP_Contents


Actions
  • Print
  • Copy Link

    https://knowledgebase.paloaltonetworks.com/KCSArticleDetail?id=kA1hj00000016cuCAA&lang=en_US&refURL=http%3A%2F%2Fknowledgebase.paloaltonetworks.com%2FKCSArticleDetail