This repository was archived by the owner on Oct 2, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConnect-Pfa2OAuth.ps1
37 lines (27 loc) · 1.51 KB
/
Connect-Pfa2OAuth.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Import-Module PureStoragePowerShellSDK2
# FlashArray IP or FQDN.
$ArrayEndpoint = "10.21.219.50"
# Unique name for this API Client.
$ArrayClientname = "foobar"
# The name of the identity provider that will be issuing ID Tokens for this API client.
$ArrayIssuer = $ArrayClientname
$ArrayPassword = ConvertTo-SecureString "Flash4All!" -AsPlainText -Force # is the FlashArray Password (SecureString).
# FlashArray username, local or AD user.
$ArrayUsername = "pureuser"
# User has on the array: array_admin, storage_admin, read_only
$MaxRole = "array_admin"
# If you created the API Client using the `New-Pfa2ArrayAuth` command there is no passphrase.
# This password should be a SecureString. This is required if the private key was generated using a passphrase.
$privateKeyPass = ConvertTo-SecureString "Pr1v@teK3y!#" -AsPlainText -Force
$FlashArrayAuthObject = New-Pfa2ArrayAuth -MaxRole $MaxRole -Endpoint $ArrayEndpoint `
-APIClientName $ArrayClientname -Issuer $ArrayIssuer -Username $ArrayUsername -Password $ArrayPassword
$FlashArrayOAuth = Connect-Pfa2Array -Endpoint $ArrayEndPoint `
-Username $ArrayUsername `
-Issuer $ArrayIssuer `
-ClientId $FlashArrayAuthObject.PureClientApiClientInfo.clientId `
-KeyId $FlashArrayAuthObject.PureClientApiClientInfo.keyId `
-PrivateKeyFile $FlashArrayAuthObject.pureCertInfo.privateKeyFile `
-PrivateKeyPassword $FlashArrayAuthObject.pureCertInfo.privateKeyPassphrase `
-IgnoreCertificateError `
-ApiClientName $ArrayClientname
$FlashArrayAuthObject