Forum Discussion

bradn2k1's avatar
bradn2k1
Novice I
3 years ago

is there a sample powershell code to connect to the

is there a sample powershell code to connect to the rest api for authentication?

4 Replies

  • I believe there was some examples somewhere in some of our kbs. I did a blog post going over some of what I ended up learning when going through it and reference some of the powershell module stuff too. https://carvertown.com/my-flasharray-rest-api-2-x-authentication-journey/
  • bradn2k1 Here is an auth article in our Platform Guide. https://support.purestorage.com/Solutions/Microsoft_Platform_Guide/a_Windows_PowerShell/How-To%3A_Connect_to_FlashArray_with_SDK_v12x
  • If you are good to only want to issue rest 1.x calls, it’s pretty easy, but I was needing to specifically issue rest 2.x calls. So it was a little bit tougher. The powershell sdk has a nice way to easily got authenticated to then invoke rest requests.
  • bradn2k1 not sure if this is what you were also looking for: ```Invoke-Pfa2RestCommand -Method GET -RelativeUri "/api/2.16/hosts" {"continuation_token":,"items":[{"is_local":true,"name":"sn1-r720-f04-03","space":{"data_reduction":1.0,"shared":,"snapshots":0,"system":,"thin_provisioning":1.0,"total_physical":0,"total_provisioned":5368709120,"total_reduction":1.0,"unique":0,"virtual":0},"host_group":{"name":},"personality":,"vlan":"","preferred_arrays":[],"iqns":[],"nqns":[],"wwns":["2100000E1E2CF050","2100000E1E2CF051"],"connection_count":1,"chap":{"host_password":,"host_user":,"target_password":,"target_user":},"port_connectivity":{"status":"unhealthy","details":"Uneven"}},{"is_local":true,"name":"sn1-r720-f04-05","space":{"data_reduction":1.0,"shared":,"snapshots":0,"system":,"thin_provisioning":1.0,"total_physical":0,"total_provisioned":1099511627776,"total_reduction":1.0,"unique":0,"virtual":0},"host_group":{"name":},"personality":,"vlan":"","preferred_arrays":[],"iqns":[],"nqns":[],"wwns":["2100000E1E1F7CD0","2100000E1E1F7CD1"],"connection_count":1,"chap":{"host_password":,"host_user":,"target_password":,"target_user":},"port_connectivity":{"status":"unhealthy","details":"Uneven"}},{"is_local":true,"name"```