Hey guys,
I searched and couldn't find anything, so apologies if this has been asked before.
We have one repository with a handful of organizations on it. We need to delete the data for one organization from the repository (user mailboxes, OneDrive, Teams, SharePoint, Groups).
I've been banging around in PowerShell for an hour and haven't made much progress.
$repo = Get-VBORepository -name "My Repository Name"
$users = Get-VBOEntityData -Type User -Repository $repo
This gets me all users on my repository across all organizations. Great. So then I try and filter out just the organization I need. I see in the VBO v6 documentation, you can add a -Organization parameter to the commands, but we're on v5 and need to stay there until we finish a support case.
$users | Where-Object {$_.Organization -eq "MyOrg"}
I have tried eq, match, like etc, and nothing returns any results, unless I use an *, which gives me everything.
I found that the Organization property is looking for type Veeam.Archiver.PowerShell.Cmdlets.DataManagement.VBOOrganizationData, so I went ahead and did this:
$org2 = Get-VBOEntityData -Type Organization -Repository $repo | Where-Object {$_.Displayname -eq "MyOrg"}
$users | Where-Object {$_.Organization -match "$org2"} (also tried all the other comparison parameters).
I still get no output. I'm stuck. Any input?
I've got some untested lines of script that will then recursively delete all the data I need, but if anyone wants to throw their suggestions out on that before I beat my ahead against another unforseen issue after this one, that would be super
P.S. - I also tried pulling users with Get-VBOOrganizationUser -Organization $org, and while that works to pull the users, it's the wrong variable type to pass onto the remove-vboentitydata command.
-
- Service Provider
- Posts: 176
- Liked: 53 times
- Joined: Mar 11, 2016 7:41 pm
- Full Name: Cory Wallace
- Contact:
-
- Product Manager
- Posts: 9848
- Liked: 2607 times
- Joined: May 13, 2017 4:51 pm
- Full Name: Fabian K.
- Location: Switzerland
- Contact:
Re: Delete all organization data from a repository
Hi Cory
You could do something like my example below for the users or sites. My code gets the username or site url from the one command to use it in the other command to get the backed up items in VBO.
I recommend to use dedicated repositories per customer and data type. Repo Best Practices. The Retention is always set on the backup repository. What happens, if one of your customer does not want the retention you offer?
Test this scripts first in your environment without deleting any data. Just to be sure that they work I had only one Organization in my lab to test the script.
You could do something like my example below for the users or sites. My code gets the username or site url from the one command to use it in the other command to get the backed up items in VBO.
I recommend to use dedicated repositories per customer and data type. Repo Best Practices. The Retention is always set on the backup repository. What happens, if one of your customer does not want the retention you offer?
Code: Select all
$org = Get-VBOOrganization -Name "aaa.onmicrosoft.com"
$repository = Get-VBORepository -Name "REPO"
$users = Get-VBOOrganizationUser -Organization $org | select username
ForEach ($user in $users)
{
$UserRemove = Get-VBOEntityData -Type User -Repository $repository -Name $user.username
Remove-VBOEntityData -Repository $repository -User $UserRemove -Mailbox -ArchiveMailbox -OneDrive -Sites
}
Code: Select all
$org = Get-VBOOrganization -Name "aaa.onmicrosoft.com"
$repository = Get-VBORepository -Name "REPO"
$sites = Get-VBOOrganizationSite -Organization $org -IncludePersonalSite | select url
ForEach ($site in $sites)
{
$siteRemove = Get-VBOEntityData -Type Site -Repository $repository -Name $site.url
Remove-VBOEntityData -Repository $repository -Site $siteRemove
}
Product Management Analyst @ Veeam Software
-
- Service Provider
- Posts: 176
- Liked: 53 times
- Joined: Mar 11, 2016 7:41 pm
- Full Name: Cory Wallace
- Contact:
Re: Delete all organization data from a repository
Hey Fabian,
Thanks for the response. Sorry for the delay, I just got back from vacation.
We're actually going to be starting a project to break each customer into their own repo. We built this out when we only had a small handful and we started with VBO v1, so it's been a while
I also needed to delete Teams and Groups as well, so I went ahead and took your script and tweaked it a bit for those. I figured I'd start with those since they are a little less risky than user mailboxes.
I added this to start:
I ran into some issues:
I tried a bunch of tweaking but couldn't get anything to work. For fun, I printed the value of $groupRemove and was shocked to find a group name that is wholly unrelated to that client. However, when I print $groups, all I see are groups from that client.
Given the fact that this seems to be a bit more challenging than it should be, this should be easier in v6, AND we're about to move all customers to their own repo and delete the old one, I'm just going to shelf this issue for now. I think the last straw for me was seeing an unrelated group from a different customer in the $removegroup variable, so I figure I should just avoid the risk of deleting other clients' data when this is about to be a non-issue anyways.
Thanks for the response. Sorry for the delay, I just got back from vacation.
We're actually going to be starting a project to break each customer into their own repo. We built this out when we only had a small handful and we started with VBO v1, so it's been a while
I also needed to delete Teams and Groups as well, so I went ahead and took your script and tweaked it a bit for those. I figured I'd start with those since they are a little less risky than user mailboxes.
I added this to start:
Code: Select all
$groups = Get-VBOOrganizationGroup -Organization $org | select DisplayName
ForEach ($group in $groups)
{
$groupRemove = Get-VBOEntityData -Type Group -Repository $repository -Name $group.DisplayName
Remove-VBOEntityData -Repository $repository -Group $groupRemove
}
Code: Select all
Remove-VBOEntityData : Cannot validate argument on parameter 'Group'. The argument is null. Provide a valid value for
the argument, and then try running the command again.
At line:4 char:53
+ Remove-VBOEntityData -Repository $repository -Group $groupRemove
+ ~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Remove-VBOEntityData], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Archiver.PowerShell.Cmdlets.BackupItems.RemoveVBO
EntityData
Given the fact that this seems to be a bit more challenging than it should be, this should be easier in v6, AND we're about to move all customers to their own repo and delete the old one, I'm just going to shelf this issue for now. I think the last straw for me was seeing an unrelated group from a different customer in the $removegroup variable, so I figure I should just avoid the risk of deleting other clients' data when this is about to be a non-issue anyways.
Who is online
Users browsing this forum: No registered users and 7 guests