Skip to content

Set-PSSMSecretStoreConfiguration

SecretManagement: Configures the SecretStore

#Requires -Version 5.1
#Requires -Modules Microsoft.PowerShell.SecretStore

[CmdletBinding()]
Param(
    [ValidateSet('None', 'Password')]
    [string]$Authentication,

    [securestring]$StorePassword,
    [int]$PasswordTimeout = 900,
    [switch]$Default
)

Process {
    try {
        $cmdArgs = @{ ErrorAction = 'Stop'; PassThru = $null; Confirm = $false }
        if ($Default) { $cmdArgs.Add('Default', $true) }
        else {
            if ($PSBoundParameters.ContainsKey('Authentication')) { $cmdArgs.Add('Authentication', $Authentication) }
            if ($PSBoundParameters.ContainsKey('StorePassword')) { $cmdArgs.Add('Password', $StorePassword) }
            if ($PSBoundParameters.ContainsKey('PasswordTimeout')) { $cmdArgs.Add('PasswordTimeout', $PasswordTimeout) }
        }
        $result = Set-SecretStoreConfiguration @cmdArgs -ErrorAction Stop | Select-Object *
        if ($null -ne $result) { $result | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force }
    }
    catch { throw }
}

Authentication method: None or Password

Password for SecretStore access

Seconds the store remains unlocked after authentication

Off

Reset to default configuration

An interactive directory of PowerShell scripts.