# 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"
