Update AdHoc-Backup.ps1

This commit is contained in:
Mattia Tadini 2025-11-10 12:57:51 +00:00
parent 500aa81ce2
commit b626f78b3a

View File

@ -473,12 +473,12 @@ function Backup-SqlDatabases {
# --- PRE-FLIGHT: Concedi a NT AUTHORITY\SYSTEM il permesso server-level 'BACKUP ANY DATABASE' ---
try {
$sqlGrant = @"
$sqlGrant = @'
USE master;
IF NOT EXISTS (SELECT 1 FROM sys.server_principals WHERE name = N'NT AUTHORITY\SYSTEM')
CREATE LOGIN [NT AUTHORITY\SYSTEM] FROM WINDOWS;
GRANT BACKUP ANY DATABASE TO [NT AUTHORITY\SYSTEM];
"@
'@
$tmpGrant = Join-Path $Paths.SqlStage "grant_SYSTEM_server.sql"
$sqlGrant | Out-File -LiteralPath $tmpGrant -Encoding ASCII -Force