Maintain control of your Microsoft 365 data
Post Reply
aleadbetterpbx
Novice
Posts: 3
Liked: never
Joined: May 17, 2021 12:40 pm
Full Name: Anthony Leadbetter
Contact:

Creating an export users script

Post by aleadbetterpbx »

Hi there!

Somewhat new to interacting with a VBO server using powershell - tend to rely on the GUI far too much. I'm looking to create a script that outputs a list of items that are currently selected for backup on an any given organisation. This list should ideally contain any Objects, as well as their Type (User/site/Shared Mailbox), and the Processes they're selected for (Mail/Archive/OneDrive). Is this possible at all, and has anyone got any pointers on setting this in a neat powershell script format?

Currently I have the following, which doesn't help alot, and leaves me without the information above, which takes in a single organisation name, and outputs very basic information for that org:

$org = Get-VBOOrganization -name 'probax.onmicrosoft.com'
$type = User
Get-VBOOrganizationUser -Organization $org -type $type

We are on VBO 5.0.1.225
Really appreciate the help here :)

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

Re: Creating an export users script

Post by Polina » 1 person likes this post

Hi Anthony,

I can't provide you the script itself, but it seems like you need to build a couple of 'foreach' loops to get arrays of all organizations and all their backup jobs and then use the Get-VBOBackupItem to list all objects included in the backup jobs.
nielsengelen
Product Manager
Posts: 5796
Liked: 1215 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Creating an export users script

Post by nielsengelen » 1 person likes this post

How are the backup jobs configured? Are you backing up the whole organisation at once or did you configure jobs with specific OneDrive/SharePoint/... settings?
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
aleadbetterpbx
Novice
Posts: 3
Liked: never
Joined: May 17, 2021 12:40 pm
Full Name: Anthony Leadbetter
Contact:

Re: Creating an export users script

Post by aleadbetterpbx »

Hi team,

Thank you for the replies - This is to grab users for a single organisation. The environment I'm working with has multiple organisations, but realistically, I just need the objects of a single organisation at anyone time. These backups are configured for OneDrive/Sharepoint/Archive for any object - and yes, they're being backed up all at once.

@polina what parameters could I use in the foreach loops to get those specific items?

Thank you again guys for the speedy responses :)
nielsengelen
Product Manager
Posts: 5796
Liked: 1215 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Creating an export users script

Post by nielsengelen » 1 person likes this post

I made the following a while ago; it will scan all your backup repositories for what is in it and list it in a CSV. You can then just filter that CSV on the organization and u should be good to go.

Example output:

Code: Select all

DisplayName               : Johanna Lorenz
Email                     : JohannaL@M365B748185.OnMicrosoft.com
AccountType               : User
Type                      : User
Organization              : M365B748185.onmicrosoft.com
Mailbox Backup            : True
Mailbox Backup Time       : 28/12/2020 8:30:25
Archive Backup            : True
Archive Backup Time       : 28/12/2020 8:30:24
OneDrive Backup           : True
OneDrive Backup Time      : 28/12/2020 8:30:22
Personal Site Backup      : True
Personal Site Backup Time : 28/12/2020 8:31:09
Script:

Code: Select all

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

$reportPath = "c:\temp\report.csv"

$repos = Get-VBORepository
$allUsers = New-Object -TypeName System.Collections.Generic.List[PSCustomObject]

foreach ($repository in $repos) {
  $users = Get-VBOEntityData -Type User -Repository $repository

  foreach ($user in $users) {
    $userDetails = [PSCustomObject]@{
                    DisplayName = $user.DisplayName;
                    Email = $user.Email;
                    AccountType = $user.AccountType;
                    Type = $user.Type;
                    Organization = $user.Organization.DisplayName;
                    "Mailbox Backup" = $user.IsMailboxBackedUp;
                    "Mailbox Backup Time" = $user.MailboxBackedUpTime;
                    "Archive Backup" = $user.IsArchiveBackedUp;
                    "Archive Backup Time" = $user.ArchiveBackedUpTime;
                    "OneDrive Backup" = $user.IsOneDriveBackedUp;
                    "OneDrive Backup Time" = $user.OneDriveBackedUpTime;
                    "Personal Site Backup" = $user.IsPersonalSiteBackedUp;
                    "Personal Site Backup Time" = $user.PersonalSiteBackedUpTime;
                }

    $allUsers.Add($userDetails)
  }
}

$allUsers | Export-Csv -Path $reportPath -NoTypeInformation
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
aleadbetterpbx
Novice
Posts: 3
Liked: never
Joined: May 17, 2021 12:40 pm
Full Name: Anthony Leadbetter
Contact:

Re: Creating an export users script

Post by aleadbetterpbx »

@neilsengelen

This is awesome. Anyway you know of that I could appropriate this for just a single organisation?

I understand that the get-VBOEntityData cmdlet HAS to take in a repository, rather than an organisation. If I want to get my users NOT from a repository, but rather from an organisation, how do you think I should do that?

Thankyou kindly for your help!
nielsengelen
Product Manager
Posts: 5796
Liked: 1215 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Creating an export users script

Post by nielsengelen »

The issue with querying against for example the backup jobs is that it becomes harder if you have backup jobs with the option "Backup the entire organization" enabled. At that point in time, you need to query against the actual backup data to split the objects (or parse the logs but in general both work).

If the organization has specific jobs, I can come up with a script.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
Post Reply

Who is online

Users browsing this forum: Brad.Barker and 17 guests