Skip to content

Commit 869354a

Browse files
add troubleshooting around kv secret add.
1 parent 3af3902 commit 869354a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Setup/Invoke-ExecUpdateRefreshToken.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,14 @@ Function Invoke-ExecUpdateRefreshToken {
3232
if ($env:TenantID -eq $Request.body.tenantId) {
3333
Set-AzKeyVaultSecret -VaultName $kv -Name 'RefreshToken' -SecretValue (ConvertTo-SecureString -String $Request.body.refreshtoken -AsPlainText -Force)
3434
} else {
35+
Write-Host "$($env:TenantID) does not match $($Request.body.tenantId) - we're adding a new secret for the tenant."
3536
$name = $Request.body.tenantId -replace '-', '_'
36-
Set-AzKeyVaultSecret -VaultName $kv -Name $name -SecretValue (ConvertTo-SecureString -String $Request.body.refreshtoken -AsPlainText -Force)
37+
try {
38+
Set-AzKeyVaultSecret -VaultName $kv -Name $name -SecretValue (ConvertTo-SecureString -String $Request.body.refreshtoken -AsPlainText -Force)
39+
} catch {
40+
Write-Host "Failed to set secret $name in KeyVault. $($_.Exception.Message)"
41+
throw $_
42+
}
3743
}
3844
}
3945
$InstanceId = Start-UpdatePermissionsOrchestrator #start the CPV refresh immediately while wizard still runs.

0 commit comments

Comments
 (0)