generated from PSModule/Template-PSModule
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚀 [Feature]: Refactor to use metdata for variables (again...) (#30)
## Description - Refactor to use metdata for variables (again...) ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [ ] 🩹 [Patch] - [ ]⚠️ [Security fix] - [x] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
- Loading branch information
1 parent
14c82f2
commit d1cf656
Showing
19 changed files
with
438 additions
and
352 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#Requires -Modules Microsoft.PowerShell.SecretManagement | ||
#Requires -Modules Microsoft.PowerShell.SecretStore | ||
|
||
function Initialize-SecretVault { | ||
<# | ||
.SYNOPSIS | ||
Initialize a SecretStore with open config. | ||
.DESCRIPTION | ||
Initialize a secret vault. If the vault does not exist, it will be created and registered. | ||
The SecretStore is created with the following parameters: | ||
- Authentication: None | ||
- PasswordTimeout: -1 (infinite) | ||
- Interaction: None | ||
- Scope: CurrentUser | ||
.EXAMPLE | ||
Initialize-SecretStore | ||
Initializes a secret vault named 'SecretStore' using the 'Microsoft.PowerShell.SecretStore' module. | ||
.NOTES | ||
For more information about secret vaults, see | ||
https://learn.microsoft.com/en-us/powershell/utility-modules/secretmanagement/overview?view=ps-modules | ||
#> | ||
[OutputType([Microsoft.PowerShell.SecretManagement.SecretVaultInfo])] | ||
[CmdletBinding()] | ||
param ( | ||
# The name of the secret vault. | ||
[Parameter()] | ||
[string] $Name = $script:Config.SecretVaultName, | ||
|
||
# The type of the secret vault. | ||
[Parameter()] | ||
[string] $Type = $script:Config.SecretVaultType | ||
) | ||
$vault = Get-SecretVault | Where-Object { $_.ModuleName -eq $Type } | ||
if (-not $vault) { | ||
Write-Verbose "[$Type] - Configuring vault type" | ||
|
||
$vaultParameters = @{ | ||
Authentication = 'None' | ||
PasswordTimeout = -1 | ||
Interaction = 'None' | ||
Scope = 'CurrentUser' | ||
WarningAction = 'SilentlyContinue' | ||
Confirm = $false | ||
Force = $true | ||
} | ||
Reset-SecretStore @vaultParameters | ||
Write-Verbose "[$Type] - Done" | ||
|
||
Write-Verbose "[$Name] - Registering vault" | ||
$secretVault = @{ | ||
Name = $Name | ||
ModuleName = $Type | ||
DefaultVault = $true | ||
Description = 'SecretStore' | ||
} | ||
Register-SecretVault @secretVault | ||
Write-Verbose "[$Name] - Done" | ||
} else { | ||
Write-Verbose "[$Name] - Vault already registered" | ||
} | ||
|
||
Get-SecretVault | Where-Object { $_.ModuleName -eq $Type } | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.