Public/Set-OnePAMConfig.ps1
|
function Set-OnePAMConfig { <# .SYNOPSIS Sets a OnePAM client configuration value. .DESCRIPTION Updates a key in ~/.onepam/config.json. Supported keys are 'api_base' and 'org_uuid'. .PARAMETER Key The configuration key to set. .PARAMETER Value The value to assign to the key. .EXAMPLE Set-OnePAMConfig -Key api_base -Value "https://my-onepam.example.com" .EXAMPLE Set-OnePAMConfig -Key org_uuid -Value "12345678-1234-1234-1234-123456789abc" #> [CmdletBinding()] param( [Parameter(Mandatory)] [ValidateSet('api_base', 'org_uuid')] [string]$Key, [Parameter(Mandatory)] [string]$Value ) $cfg = Get-OpConfig switch ($Key) { 'api_base' { Assert-OpValidApiBase -Url $Value $cfg.api_base = $Value.TrimEnd('/') } 'org_uuid' { $cfg.org_uuid = $Value } } Save-OpConfig $cfg Write-Host "Configuration updated: $Key = $Value" -ForegroundColor Green } |