powershell - backup every 4 hours

I need to make backups of my system state on my windows 2016 server hyper-v domain controller. The only way for this to work is thru power shell. I am only able to run this for one time. How do I write this t run every 4 hours in PowerShell?

# Runs  from PS on DC1
Register-ScheduledJob -Name “System State Backup” -Trigger @{Frequency = “Daily”; At = “2:00”} -ScriptBlock {
	# Create new Backup Policy
	$Policy = New-WBPolicy

	# Add System State to the policy
	Add-WBSystemState -Policy $Policy

	# Set Backup Location
	$BackupLocation = New-WBBackupTarget -VolumePath "\\bugsbunny\svrA"

	# Add backup location to policy
	Add-WBBackupTarget -Policy $Policy -Target $BackupLocation

	# Start Backup Using Policy
	Start-WBBackup -Policy $Policy

Open in new window

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

DevAdminSystem Engineer | .NET Developer | Microsoft MVP | Technical SpeakerCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RobertSystem AdminCommented:
If the scheduled job is not working  it could be that since your not passing credentials the scheduled job is not able to run.


You could just save the script as a ps1 and schedule it via task scheduler.
if you are doing AD system state backup with windows server backup, you can simply use GUI to schedule backup every 4 HRS

If this is core server you can use command line option
wbadmin enable backup -addtarget:F: -schedule:00:00,04:00,08:00,12:00,16:00,20:00 -systemState -quiet 

Open in new window

Jose Gabriel Ortega CastroEE Solution Guide/Topic Advisor and CEO Faru Bonon ITCommented:
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Just add -RunEvery (New-Timespan -hours 4) to your Register-ScheduledJob.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.