Maintain control of your Microsoft 365 data
Post Reply
Jharvick
Lurker
Posts: 1
Liked: never
Joined: Mar 15, 2019 12:29 pm
Contact:

Shutdown Script

Post by Jharvick »

Hello everybody,

i have this script to check if a job is running on Veeam Backup and Replication.:


$jobsworking = @(Get-VBRJob| Where {$_.GetLastState() -eq "Working"} )
if ($jobsworking.Count -gt 0) {
write-host "Jobs are still working"
} else {

write-host "Nothing is working, let's shutdown machines"
}


But it does not work for Veeam Backup for Microsoft Office 365.
What can i do?

Best Regards
Polina
Veeam Software
Posts: 3195
Liked: 774 times
Joined: Oct 21, 2011 11:22 am
Full Name: Polina Vasileva
Contact:

Re: Shutdown Script

Post by Polina »

Hi Jharvick,

First of all, VBO has its own PowerShell reference with its own specific cmdlets. Thus, instead of the 'Get-VBRJob', you need to use the 'Get-VBOJob' command; and to the best of my knowledge, it's only possible to get the jobs' LastRun or NextRun info. However, I'll double check on this and get back to you if there're any options to get the job's running state.
nielsengelen
Product Manager
Posts: 5797
Liked: 1215 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Shutdown Script

Post by nielsengelen »

Keep in mind, VBO Archive service will wake up your computer. What would be the purpose of shutting down the computer?
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
Polina
Veeam Software
Posts: 3195
Liked: 774 times
Joined: Oct 21, 2011 11:22 am
Full Name: Polina Vasileva
Contact:

Re: Shutdown Script

Post by Polina »

Jharvick,

Upon a double check with the QC, in VBO, LastStatus parameter will give you the job's running/not running state.
Gerald
Influencer
Posts: 13
Liked: 2 times
Joined: Sep 04, 2015 5:56 pm
Full Name: Gerald
Contact:

Re: Shutdown Script

Post by Gerald » 1 person likes this post

Here is a finished working Powershell script to do what was asked for, I had the same wish as the original poster here.

Code: Select all

$jobsfinished = $false

while ($jobsfinished -eq $false)
    {
	$jobsworkingcount = @(Get-VBOJob | Where LastStatus -eq 'Running').Count
	if ($jobsworkingcount -eq 0)
	{
		write-host "All jobs have finished!"
		$jobsfinished = $true
	}
	else
	{
		write-host "$jobsworkingcount jobs are still working, sleeping for 60s..."
		Start-Sleep -s 60
	}
    }


write-host "Nothing is working, let's shutdown machine in 120 seconds..."
Start-Sleep -s 120
Stop-Computer -Force

Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests