From 851b807c1fa0a63ae0b6cc0cb10fe8c4d4c2aab6 Mon Sep 17 00:00:00 2001 From: fuenmao <980740792@qq.com> Date: Thu, 29 Oct 2026 14:26:48 +0800 Subject: [PATCH] 111 --- encrypt-key.ps1 | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/encrypt-key.ps1 b/encrypt-key.ps1 index 9d7da09..4e3339b 100644 --- a/encrypt-key.ps1 +++ b/encrypt-key.ps1 @@ -2,11 +2,23 @@ [CmdletBinding()] param( [switch]$UpdateConfig, - [string]$ConfigPath = (Join-Path $PSScriptRoot 'appsettings.Development.json') + [string]$ConfigPath ) $ErrorActionPreference = 'Stop' +if ([string]::IsNullOrWhiteSpace($ConfigPath)) { + $scriptDirectory = $PSScriptRoot + if ([string]::IsNullOrWhiteSpace($scriptDirectory) -and + -not [string]::IsNullOrWhiteSpace($MyInvocation.MyCommand.Path)) { + $scriptDirectory = Split-Path -Parent $MyInvocation.MyCommand.Path + } + if ([string]::IsNullOrWhiteSpace($scriptDirectory)) { + throw 'Cannot determine the script directory. Specify -ConfigPath with the full config path.' + } + $ConfigPath = Join-Path $scriptDirectory 'appsettings.Development.json' +} + function ConvertTo-EncryptedValue { param( [Security.SecureString]$Value,