Maintain control of your Microsoft Office 365 email data
Post Reply
mschwarzer
Influencer
Posts: 11
Liked: never
Joined: Oct 22, 2018 8:31 am
Full Name: Michael Schwarzer
Contact:

powershell - query vbojobsession

Post by mschwarzer » May 22, 2019 2:00 pm

Hi @ll,

we devided the organisation backup for the exchange backup into user-dependent jobs.
We query the exchange-online for the list of fully lincensed boxes and add them to the different jobs. When a user left the company the job will run into an warning, that the exo account is not found any more. This is usefull to generate an event and to export the latest backuppoint to worm.

My question is, to automate this a cmdlet or query whould be nice to go one step deeper than
Get-VBOJobSession - Job $job -Last
Is there a query to get the last backup result of a JobSession-action ?

Hope some of you find this interresting too and Best regards,
Michael

Mike Resseler
Product Manager
Posts: 5759
Liked: 615 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

Re: powershell - query vbojobsession

Post by Mike Resseler » May 27, 2019 7:22 am

Hey Michael,

Sorry for our late reply (VeeamON was fantastic but extremely busy for us ;-)).

I am not sure what you want to know. If you work with Get-VBOJobSession -Job $job -Last you do get the latest result for that job? Then you can see at the status parameter (Disconnected, Failed, NotConfigured, Queued, Running, Stopped, Success, Warning) should give you that information? (Or am I not understanding the question correctly...)

Thanks
Mike

mschwarzer
Influencer
Posts: 11
Liked: never
Joined: Oct 22, 2018 8:31 am
Full Name: Michael Schwarzer
Contact:

Re: powershell - query vbojobsession

Post by mschwarzer » May 27, 2019 8:37 am

Hi Mike,

thanks for reply. ICan imagine, there is a lot of things to be done around the new version.
What i try to automate is the export of last successfull running backup of a specific box to offline storage. Usually after a box was unlicensed within exchange, the referencing job at veeam4O365-site is running into warning. In the UI the tasklist is showning an entry for the unlicensed user like:
$timestamp :: Processing mailbox $user completed with warning: User was not found: $user (ID: $exo-userID)
If it, whould be possible to catch this event, it is possible to automate the export-to-pst --> to offline storage. Perhaps there is a query targeting against the backup timestamp, restore-point or so, to get this task event.?

Kind regards,
Michael

mschwarzer
Influencer
Posts: 11
Liked: never
Joined: Oct 22, 2018 8:31 am
Full Name: Michael Schwarzer
Contact:

Re: powershell - query vbojobsession

Post by mschwarzer » May 27, 2019 11:34 am

Hello,
i think i was mind blocked a bit using powershell reference. The simpliest way of getting what i need ist using: https://helpcenter.veeam.com/docs/vbo36 ... tml?ver=30

Cheers and Br,
Michael

Mike Resseler
Product Manager
Posts: 5759
Liked: 615 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

Re: powershell - query vbojobsession

Post by Mike Resseler » May 28, 2019 4:23 am

Awesome! If you have feedback for our technical writers, please use the feedback links which exists on each page. Trust me when I say they love that kind of feedback and are always looking for suggestions for improvements.

mschwarzer
Influencer
Posts: 11
Liked: never
Joined: Oct 22, 2018 8:31 am
Full Name: Michael Schwarzer
Contact:

Re: powershell - query vbojobsession

Post by mschwarzer » May 29, 2019 5:46 am

Thanks Mike,
Got the export running with a little help from BasvanH using https://gist.github.com/BasvanH/2229ca0 ... db36d7bc5c - very usefull for those making there first steps with querying the veem4O365 RestAPI.
But one thing is still open. To be able to remove the exported users from jobs, i first have to
Remove-VBOBackupItem -Job $job -BackupItem ( New-VBOBackupItem -User ( Get-VBOOrganizationUser -Organization $org -Name $export -Type User ) )
which will fail to bind the userobjekt ($export) in case of nox-existent exo account.

My question is: Is there a way to force the binding of the VBOOrganisationUser element (exception handling or so) to be able to remove it per cmd, like in the ui were it is possible?

Mike Resseler
Product Manager
Posts: 5759
Liked: 615 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

Re: powershell - query vbojobsession

Post by Mike Resseler » May 29, 2019 5:50 am

Michael,

I'm not sure I understand what you want. So you have exported the data. Correct? Then you want to remove the data? And finally remove the job? Is that correct?

mschwarzer
Influencer
Posts: 11
Liked: never
Joined: Oct 22, 2018 8:31 am
Full Name: Michael Schwarzer
Contact:

Re: powershell - query vbojobsession

Post by mschwarzer » May 29, 2019 6:05 am

Hi, nope. I exported the data from the repo to some offline storage. Now the job, containing a list of userobjekts (mail/archive) is still backing up a user which does not have a licensed box in exo and generating a warning. This i try to avoid by removing the user from the job.

Mike Resseler
Product Manager
Posts: 5759
Liked: 615 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

Re: powershell - query vbojobsession

Post by Mike Resseler » May 29, 2019 6:11 am

Ok, I understand it now. Unfortunately I have no access to some of the scripts and I don't know it out of my head but this is what you need to do:

First: Get the data from the backup job and (Get-VBOJob). One of the parameters in the object that you will retrieve will have the list of included items (e.g. the users). Then you need to filter that one specific out and use Set-VBOJob to update the list of included items again. I am aware it isn't that straightforward. Let me try to contact Niels who has written a few of those scripts. If he is in the office I am sure he can help you with this.

nielsengelen
Veeam Software
Posts: 2690
Liked: 556 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: powershell - query vbojobsession

Post by nielsengelen » Jun 05, 2019 1:21 pm 2 people like this post

Michael,

I have a script which works for Exchange users that are no longer present; you may need to adjust the message to fit those who are missing (as I don't know the exact warning you are receiving). Just replace the JobName (TEST) with the correct name.

Code: Select all

Import-Module "C:\Program Files\Veeam\Backup365\Veeam.Archiver.PowerShell\Veeam.Archiver.PowerShell.psd1"

$JobName = "TEST"

$Job = Get-VBOJob -Name $JobName
$JobSession = Get-VBOJobSession -Job $Job -Last
$SelectedItems = $Job.SelectedItems
$SelectedUser = $Job.SelectedItems.User
$JobLog = $JobSession.Log

$Seperator = '\[Warning\].*(Exchange\saccount\swas\snot\sfound)'
$Warnings = $JobLog.Title -match "$Seperator"

foreach ($JobWarning in $Warnings) {
    $UID = $JobWarning.Split('(ID: ')
    $UID = $UID[-1].TrimEnd(')')

    $RemoveUser = $SelectedItems | Where-Object {$_.User.OfficeId -eq $UID}
    $DisplayName = $($SelectedUser | Where-Object {$_.OfficeId -eq $UID} | Select-Object -ExpandProperty DisplayName)
    
    try {
        Remove-VBOBackupItem -Job $job -BackupItem $RemoveUser -ErrorAction Stop
        Write-Host -ForegroundColor Green "User named '$DisplayName' with GUID '$UID' has been removed from backup job '$($Job.Name)'."
    } catch {
        Write-Host -ForegroundColor Red "User named '$DisplayName' with GUID '$UID' could not be removed from backup job '$($Job.Name)'."
    }
}
VCP-DCV
Veeam Certified Architect (VMCA)
http://foonet.be

Post Reply

Who is online

Users browsing this forum: No registered users and 6 guests