Scheduling a system state backup for your Domain Controller

I don’t know what to write in this block, it is very self-explanatory. If you reached this post it means you are already aware of what a system state backup of domain controller means. This script is to help you schedule it as a job, it will delete backups older than 90 days.

1
2
3
4
5
6
7
8
9
$old = (get-date).AddDays(-90)
Get-ChildItem "\\server\Backups\DC State Backup\DomainControllerName\SystemState" | ?{$_.CreationTime -le $old} |Remove-Item -Force
$BackUpDir = "\\\server\Backups\DC State Backup\DomainControllerName\SystemState\$(Get-Date -Format MMddyyyy)"
New-Item -ItemType Directory $BackUpDir
$BackupLocation = New-WBBackupTarget -Network $BackUpDir
$Policy = New-WBPolicy
Add-WBSystemState -Policy $Policy
Add-WBBackupTarget -Policy $Policy -Target $BackupLocation
Start-WBBackup -Policy $Policy

Be the first to comment

Leave a Reply

Your email address will not be published.


*