-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathconfirmAccepted-api.ps1
More file actions
35 lines (27 loc) · 1.67 KB
/
confirmAccepted-api.ps1
File metadata and controls
35 lines (27 loc) · 1.67 KB
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
#Depends on file "secureString.txt" which can be created by first running `Read-Host "Enter Password" -AsSecureString | ConvertFrom-SecureString | Out-File "secureString.txt"`
#Use this to store your API client_secret
#Depends on file "secureString2.txt" which can be created by first running `Read-Host "Enter Password" -AsSecureString | ConvertFrom-SecureString | Out-File "secureString2.txt"`
#Use this to store your Master Password to unlock your Vault
$organization_id = "b9c70d44-2615-4c84-9913-ac330139c9eb"
$user = "admin-or-manage-users-privileged-account@yourdomain.com"
$BW_CLIENTID = "account settings -> security -> keys -> view api key -> client_id"
$secret = Get-Content "secureString.txt" | ConvertTo-SecureString
$cred = New-Object System.Management.Automation.PSCredential "null", $secret
$password = Get-Content "secureString2.txt" | ConvertTo-SecureString
$cred2 = New-Object System.Management.Automation.PSCredential "null", $password
$status = .\bw status | ConvertFrom-Json | Select-Object -ExpandProperty status
if ($status -eq "unauthenticated") {
$env:BW_CLIENTSECRET=$cred.GetNetworkCredential().password
.\bw login --apikey | Out-Null
}
$session_key = , $cred2.GetNetworkCredential().password | powershell -c '.\bw unlock --raw'
$org_members_object = .\bw list --session $session_key org-members --organizationid $organization_id | ConvertFrom-Json
$org_members = $org_members_object | Where-Object { $_.status -eq 1 } | Select-Object -ExpandProperty id
if ($org_members -eq $null) {
write-host "Nothing to do here"
}
else {
ForEach ($member_id in $org_members.trim('"')) {
.\bw confirm --session $session_key org-member $member_id --organizationid $organization_id
}
}