|
| 1 | +function Get-GSDecryptedConfig { |
| 2 | + [CmdletBinding()] |
| 3 | + Param( |
| 4 | + [parameter(Position = 0,ValueFromPipeline,Mandatory)] |
| 5 | + [object] |
| 6 | + $Config, |
| 7 | + [parameter(Position = 1,Mandatory)] |
| 8 | + [string] |
| 9 | + $ConfigName, |
| 10 | + [parameter(Position = 2)] |
| 11 | + [string] |
| 12 | + $ConfigPath |
| 13 | + ) |
| 14 | + Process { |
| 15 | + $Config | Select-Object -Property ` |
| 16 | + @{l = 'ConfigName';e = { $ConfigName }}, |
| 17 | + @{l = 'P12KeyPath'; e = { Invoke-GSDecrypt $_.P12KeyPath } }, |
| 18 | + 'P12Key', |
| 19 | + @{l = 'P12KeyPassword'; e = { Invoke-GSDecrypt $_.P12KeyPassword } }, |
| 20 | + @{l = 'P12KeyObject'; e = { Invoke-GSDecrypt $_.P12KeyObject } }, |
| 21 | + @{l = 'ClientSecretsPath'; e = { Invoke-GSDecrypt $_.ClientSecretsPath } }, |
| 22 | + @{l = 'ClientSecrets'; e = { Invoke-GSDecrypt $_.ClientSecrets } }, |
| 23 | + @{l = 'AppEmail'; e = { |
| 24 | + if ($_.AppEmail) { |
| 25 | + Invoke-GSDecrypt $_.AppEmail |
| 26 | + } |
| 27 | + elseif ($_.ClientSecrets) { |
| 28 | + (Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_email |
| 29 | + } |
| 30 | + } |
| 31 | + }, |
| 32 | + @{l = 'AdminEmail'; e = { Invoke-GSDecrypt $_.AdminEmail } }, |
| 33 | + @{l = 'CustomerID'; e = { Invoke-GSDecrypt $_.CustomerID } }, |
| 34 | + @{l = 'Domain'; e = { Invoke-GSDecrypt $_.Domain } }, |
| 35 | + @{l = 'Preference'; e = { Invoke-GSDecrypt $_.Preference } }, |
| 36 | + @{l = 'ServiceAccountClientID'; e = { |
| 37 | + if ($_.ServiceAccountClientID) { |
| 38 | + Invoke-GSDecrypt $_.ServiceAccountClientID |
| 39 | + } |
| 40 | + elseif ($_.ClientSecrets) { |
| 41 | + (Invoke-GSDecrypt $_.ClientSecrets | ConvertFrom-Json).client_id |
| 42 | + } |
| 43 | + } |
| 44 | + }, |
| 45 | + @{l = 'Chat'; e = { |
| 46 | + $dict = @{ |
| 47 | + Webhooks = @{ } |
| 48 | + Spaces = @{ } |
| 49 | + } |
| 50 | + foreach ($key in $_.Chat.Webhooks.Keys) { |
| 51 | + $dict['Webhooks'][$key] = (Invoke-GSDecrypt $_.Chat.Webhooks[$key]) |
| 52 | + } |
| 53 | + foreach ($key in $_.Chat.Spaces.Keys) { |
| 54 | + $dict['Spaces'][$key] = (Invoke-GSDecrypt $_.Chat.Spaces[$key]) |
| 55 | + } |
| 56 | + $dict |
| 57 | + } |
| 58 | + }, |
| 59 | + @{l = 'ConfigPath'; e = { |
| 60 | + if ($ConfigPath) {(Resolve-Path $ConfigPath).Path} elseif ($_.ConfigPath) {$_.ConfigPath} else {$null} |
| 61 | + }} |
| 62 | + } |
| 63 | +} |
1 | 64 | function Invoke-GSDecrypt {
|
2 | 65 | param($String)
|
3 | 66 | if ($String -is [System.Security.SecureString]) {
|
|
0 commit comments