DBAForever
New Member
- Joined
- Aug 1, 2024
- Messages
- 2
Get-ScheduledTask | Where-Object {$_.Triggers.StartBoundary -like "*12:00:00AM"} | Select-Object TaskName, TaskPath
Get-ScheduledTask | Where-Object {$_.Triggers.StartBoundary -like "*12:00:00AM"} | Select-Object TaskName, TaskPath
Get-ScheduledTask | Where-Object {$_.Actions.Execute -match "sqlcmd|powershell|backup"} | Select-Object TaskName, TaskPath
$tasks = Get-ScheduledTask foreach ($task in $tasks) { $details = schtasks /Query /TN $task.TaskName /V /FO LIST if ($details -like "*12:00:00 AM*") { Write-Output $details } }
If you know the elements of the tasks you can still filter them in PowerShell, but it sounds like some kind of nightmare. Instructions should still be valid, or have to use the GUI...... This is the Express Edition so there is no SQL JOb Agent. I omitted that essential fact
Win + R
, type taskschd.msc
, press Enter).sqlcmd
or run a backup .bat
script.sqlcmd
or custom .bat
files. Locate these files:.bat
or .sql
files related to SQL commands:cmd dir C:\ /s /p *.bat dir C:\ /s /p *.sql
sqlcmd
.sql SELECT database_name, backup_start_date, backup_finish_date, type, physical_device_name FROM msdb.dbo.backupset INNER JOIN msdb.dbo.backupmediafamily ON backupset.media_set_id = backupmediafamily.media_set_id ORDER BY backup_finish_date DESC
msdb
(which is often limited)..bat
script and schedule it with Task Scheduler for future backups..bat
script:cmd sqlcmd -S .\SQLEXPRESS -E -Q "BACKUP DATABASE YourDatabaseName TO DISK='C:\Backups\YourDatabaseName.bak' WITH INIT;"