Skip to content

Commit d123b5d

Browse files
Action Pack PowerShell Secret Management
1 parent 4a96b54 commit d123b5d

18 files changed

+1109
-0
lines changed
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#Requires -Version 5.0
2+
#Requires -Modules Microsoft.PowerShell.SecretManagement,Microsoft.PowerShell.SecretStore
3+
4+
<#
5+
.SYNOPSIS
6+
Finds and returns a secret by name from registered vaults
7+
8+
.DESCRIPTION
9+
10+
.NOTES
11+
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
12+
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
13+
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
14+
the use and the consequences of the use of this freely available script.
15+
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
16+
© ScriptRunner Software GmbH
17+
18+
.COMPONENT
19+
Requires Module Microsoft.PowerShell.SecretManagement,Microsoft.PowerShell.SecretStore
20+
21+
.LINK
22+
https://github.com/scriptrunner/ActionPacks/tree/master/PowerShell Secretmanagement
23+
24+
.Parameter SecretName
25+
[sr-en] Name of the secret
26+
[sr-de] Secret-Name
27+
28+
.Parameter VaultName
29+
[sr-en] Name of the vault
30+
[sr-de] Vault-Name
31+
32+
.Parameter AsPlainText
33+
[sr-en] Secret should be returned as a String
34+
[sr-de] Secret als Text ausgeben
35+
36+
.Parameter StorePassword
37+
[sr-en] Password needed to access the store
38+
[sr-de] Kennwort für den Store Zugriff
39+
#>
40+
41+
param(
42+
[Parameter(Mandatory = $true)]
43+
[string]$SecretName,
44+
[securestring]$StorePassword,
45+
[string]$VaultName,
46+
[switch]$AsPlainText
47+
)
48+
49+
Import-Module Microsoft.PowerShell.SecretManagement
50+
Import-Module Microsoft.PowerShell.SecretStore
51+
52+
try{
53+
if($null -ne $StorePassword){
54+
Unlock-SecretStore -Password $StorePassword
55+
}
56+
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
57+
'Name' = $SecretName
58+
'AsPlainText' = $AsPlainText
59+
}
60+
if($PSBoundParameters.ContainsKey('VaultName') -eq $true){
61+
$cmdArgs.Add('Vault',$VaultName)
62+
}
63+
$sec = Get-Secret @cmdArgs
64+
65+
if($null -ne $SRXEnv) {
66+
$SRXEnv.ResultMessage = $sec
67+
}
68+
else{
69+
Write-Output $sec
70+
}
71+
}
72+
catch{
73+
throw
74+
}
75+
finally{
76+
}
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#Requires -Version 5.0
2+
#Requires -Modules Microsoft.PowerShell.SecretManagement,Microsoft.PowerShell.SecretStore
3+
4+
<#
5+
.SYNOPSIS
6+
Finds and returns metadata information about secrets in registered vaults
7+
8+
.DESCRIPTION
9+
10+
.NOTES
11+
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
12+
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
13+
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
14+
the use and the consequences of the use of this freely available script.
15+
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
16+
© ScriptRunner Software GmbH
17+
18+
.COMPONENT
19+
Requires Module Microsoft.PowerShell.SecretManagement,Microsoft.PowerShell.SecretStore
20+
21+
.LINK
22+
https://github.com/scriptrunner/ActionPacks/tree/master/PowerShell Secretmanagement
23+
24+
.Parameter SecretName
25+
[sr-en] Name of the secret
26+
[sr-de] Secret-Name
27+
28+
.Parameter VaultName
29+
[sr-en] Name of the vault
30+
[sr-de] Vault-Name
31+
32+
.Parameter StorePassword
33+
[sr-en] Password needed to access the store
34+
[sr-de] Kennwort für den Store Zugriff
35+
#>
36+
37+
param(
38+
[Parameter(Mandatory = $true)]
39+
[string]$SecretName,
40+
[securestring]$StorePassword,
41+
[string]$VaultName
42+
)
43+
44+
Import-Module Microsoft.PowerShell.SecretManagement
45+
Import-Module Microsoft.PowerShell.SecretStore
46+
47+
try{
48+
if($null -ne $StorePassword){
49+
Unlock-SecretStore -Password $StorePassword
50+
}
51+
if([System.String]::IsNullOrWhiteSpace($SecretName) -eq $true){
52+
$SecretName = '*'
53+
}
54+
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
55+
'Name' = $SecretName
56+
}
57+
if($PSBoundParameters.ContainsKey('VaultName') -eq $true){
58+
$cmdArgs.Add('Vault',$VaultName)
59+
}
60+
$sec = Get-SecretInfo @cmdArgs | Select-Object *
61+
62+
if($null -ne $SRXEnv) {
63+
$SRXEnv.ResultMessage = $sec
64+
}
65+
else{
66+
Write-Output $sec
67+
}
68+
}
69+
catch{
70+
throw
71+
}
72+
finally{
73+
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#Requires -Version 5.0
2+
#Requires -Modules Microsoft.PowerShell.SecretStore
3+
4+
<#
5+
.SYNOPSIS
6+
Returns SecretStore configuration information
7+
8+
.DESCRIPTION
9+
10+
.NOTES
11+
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
12+
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
13+
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
14+
the use and the consequences of the use of this freely available script.
15+
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
16+
© ScriptRunner Software GmbH
17+
18+
.COMPONENT
19+
Requires Module Microsoft.PowerShell.SecretStore
20+
21+
.LINK
22+
https://github.com/scriptrunner/ActionPacks/tree/master/PowerShell Secretmanagement
23+
#>
24+
25+
param(
26+
)
27+
28+
Import-Module Microsoft.PowerShell.SecretStore
29+
30+
try{
31+
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'}
32+
$sec = Get-SecretStoreConfiguration @cmdArgs
33+
34+
if($null -ne $SRXEnv) {
35+
$SRXEnv.ResultMessage = $sec
36+
}
37+
else{
38+
Write-Output $sec
39+
}
40+
}
41+
catch{
42+
throw
43+
}
44+
finally{
45+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#Requires -Version 5.0
2+
#Requires -Modules Microsoft.PowerShell.SecretManagement
3+
4+
<#
5+
.SYNOPSIS
6+
Finds and returns registered vault information
7+
8+
.DESCRIPTION
9+
10+
.NOTES
11+
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
12+
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
13+
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
14+
the use and the consequences of the use of this freely available script.
15+
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
16+
© ScriptRunner Software GmbH
17+
18+
.COMPONENT
19+
Requires Module Microsoft.PowerShell.SecretManagement
20+
21+
.LINK
22+
https://github.com/scriptrunner/ActionPacks/tree/master/PowerShell Secretmanagement
23+
24+
.Parameter VaultName
25+
[sr-en] Name of the vault
26+
[sr-de] Vault-Name
27+
#>
28+
29+
param(
30+
[string]$VaultName
31+
)
32+
33+
Import-Module Microsoft.PowerShell.SecretManagement
34+
35+
try{
36+
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'}
37+
if($PSBoundParameters.ContainsKey('VaultName') -eq $true){
38+
$cmdArgs.Add('Name',$VaultName)
39+
}
40+
$vault = Get-SecretVault @cmdArgs | Select-Object *
41+
42+
if($null -ne $SRXEnv) {
43+
$SRXEnv.ResultMessage = $vault
44+
}
45+
else{
46+
Write-Output $vault
47+
}
48+
}
49+
catch{
50+
throw
51+
}
52+
finally{
53+
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
#Requires -Version 5.0
2+
#Requires -Modules Microsoft.PowerShell.SecretManagement,Microsoft.PowerShell.SecretStore
3+
4+
<#
5+
.SYNOPSIS
6+
Registers a SecretManagement extension vault module for the current user
7+
8+
.DESCRIPTION
9+
10+
.NOTES
11+
This PowerShell script was developed and optimized for ScriptRunner. The use of the scripts requires ScriptRunner.
12+
The customer or user is authorized to copy the script from the repository and use them in ScriptRunner.
13+
The terms of use for ScriptRunner do not apply to this script. In particular, ScriptRunner Software GmbH assumes no liability for the function,
14+
the use and the consequences of the use of this freely available script.
15+
PowerShell is a product of Microsoft Corporation. ScriptRunner is a product of ScriptRunner Software GmbH.
16+
© ScriptRunner Software GmbH
17+
18+
.COMPONENT
19+
Requires Module Microsoft.PowerShell.SecretManagement,Microsoft.PowerShell.SecretStore
20+
21+
.LINK
22+
https://github.com/scriptrunner/ActionPacks/tree/master/PowerShell Secretmanagement
23+
24+
.Parameter VaultName
25+
[sr-en] Name of the new vault
26+
[sr-de] Vault-Name
27+
28+
.Parameter Description
29+
[sr-en] Description
30+
[sr-de] Beschreibung
31+
32+
.Parameter DefaultVault
33+
[sr-en] Set the new vault as default vault
34+
[sr-de] Vault als Standard-Vault konfigurieren
35+
36+
.Parameter OverwriteExistingVault
37+
[sr-en] Overwrite an existing registered extension vault with the same name
38+
[sr-de] Überschreiben eines existierenden Vaults mit dem selben Namen
39+
#>
40+
41+
param(
42+
[Parameter(Mandatory = $true)]
43+
[string]$VaultName,
44+
[string]$Description,
45+
[switch]$DefaultVault,
46+
[switch]$OverwriteExistingVault
47+
)
48+
49+
Import-Module Microsoft.PowerShell.SecretManagement
50+
Import-Module Microsoft.PowerShell.SecretStore
51+
52+
try{
53+
[hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'
54+
'ModuleName' = 'Microsoft.PowerShell.SecretStore'
55+
'Name' = $VaultName
56+
'AllowClobber' = $OverwriteExistingVault
57+
'DefaultVault' = $DefaultVault
58+
'Confirm' = $false
59+
'PassThru' = $null
60+
}
61+
if($PSBoundParameters.ContainsKey('Description') -eq $true){
62+
$cmdArgs.Add('Description',$Description)
63+
}
64+
$vault = Register-SecretVault @cmdArgs
65+
66+
if($null -ne $SRXEnv) {
67+
$SRXEnv.ResultMessage = $vault
68+
}
69+
else{
70+
Write-Output $vault
71+
}
72+
}
73+
catch{
74+
throw
75+
}
76+
finally{
77+
}

0 commit comments

Comments
 (0)