Add SQLAgent folder

This commit is contained in:
Neeraj Kumar
2025-10-06 08:06:01 -04:00
parent 5254db068f
commit a261268b5d
94 changed files with 4419 additions and 0 deletions

View File

@ -0,0 +1,16 @@
# Example PowerShell snippet
$Server = "DOES-DUTAS-SQL1"
$BackupPath = "\\DOES-RAINVM-DEV\E$\Neeraj\SqlAgent\Backup\"
$Timestamp = Get-Date -Format "yyyyMMdd_HHmmss"
$ZipFile = "$BackupPath\SQLAgentJobs_$Timestamp.zip"
# Make backup folder if not exist
if (-not (Test-Path $BackupPath)) { New-Item -ItemType Directory -Path $BackupPath }
# Export all jobs as SQL files
sqlcmd -S $Server -Q "EXEC msdb.dbo.sp_help_job" -o "$BackupPath\SQLAgentJobs_$Timestamp.txt"
# Compress to zip
Compress-Archive -Path "$BackupPath\*" -DestinationPath $ZipFile -Force
Write-Host "✅ Backup complete: $ZipFile"