Content Filtering with Powershell command

Hello,

I am new to powershell and working on one of the project where i have to gather the password from the Cyberark using its API.

I am getting below Output when i execute the CyberArk API for password.

{“Content”:“n>*<Dy8uM$b.4F3h”,“PolicyID”:“JAMES_AD_WIN_SVC_Managed_C90”,“LastTask”:“ChangeTask”,“UserName”:“SVC_TJOIN",“CPMStatus”:“success”,“Folder”:“Root”,“Safe”:“HELLO_PROD_WIN_Myhouse”,“Address”:“hello.bye.hello.com”,“Name”:"Operating System-JAMES_AD_WIN_SVC_Managed_C90-hello.bye.hello.com-SVC_TJOIN”,“LogonDomain”:“ONE”,“DeviceType”:“Operating System”,“RetriesCount”:“-1”,“LastSuccessChange”:“1663434325”,“CreationMethod”:“PVWA”,“PasswordChangeInProcess”:“False”}

In above output n>*<Dy8uM$b.4F3h is the password and rest of the content i wanted to delete and only that password i want to use.

I am not sure how i can do this, Can you pls guide me on this?

Hi, welcome to the forum :wave:

Firstly, when posting code in the forum, please can you use the preformatted text </> button. It really helps us with readability, and copying and pasting your code (we don’t have to faff about replacing curly quote marks to get things working).

How to format code on PowerShell.org

That looks like a JSON response so something like this should work:

$response = Invoke-RestMethod <API Stuff>
$password = $response.Content

Thanks, will make sure of it and thanks it worked for me.

Formatting