-
- Influencer
- Posts: 14
- Liked: 1 time
- Joined: Apr 29, 2013 1:10 pm
- Contact:
Delete oprhaned users
I have deleted an organization from GUI. The data still remain in the database. How do I go about deleting all the data related to this organization?
I tried this, but it doesn't return anything:
Get-VBOEntityData -Type User -Repository $repository | Where {$_.Organization -like "orgiwanttodelete"}
If I do:
Get-VBOEntityData -Type User -Repository $repository
I can see a lot of users with the organization property I want to delete.
I don't understand why there isn't simply a "Do you want to delete this organizations data as well" option in the GUI when you delete organizations.
It is disrespectful of our time to not implement such low hanging fruit.
I tried this, but it doesn't return anything:
Get-VBOEntityData -Type User -Repository $repository | Where {$_.Organization -like "orgiwanttodelete"}
If I do:
Get-VBOEntityData -Type User -Repository $repository
I can see a lot of users with the organization property I want to delete.
I don't understand why there isn't simply a "Do you want to delete this organizations data as well" option in the GUI when you delete organizations.
It is disrespectful of our time to not implement such low hanging fruit.
-
- Product Manager
- Posts: 5796
- Liked: 1215 times
- Joined: Jul 15, 2013 11:09 am
- Full Name: Niels Engelen
- Contact:
Re: Delete oprhaned users
You can remove data from a repository using Remove-VBOEntityData.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
GitHub: https://github.com/nielsengelen
-
- Influencer
- Posts: 14
- Liked: 1 time
- Joined: Apr 29, 2013 1:10 pm
- Contact:
Re: Delete oprhaned users
I know of the cmdlet. If you read my entire post, you can see that I don't understand how to apply the cmdlet. Hence my post.
-
- Product Manager
- Posts: 5796
- Liked: 1215 times
- Joined: Jul 15, 2013 11:09 am
- Full Name: Niels Engelen
- Contact:
Re: Delete oprhaned users
The following should do it:
Code: Select all
Import-Module "C:\Program Files\Veeam\Backup365\Veeam.Archiver.PowerShell\Veeam.Archiver.PowerShell.psd1"
$repo = Get-VBORepository -Name "Default Backup Repository" # Change this to match your repository
$org = Get-VBOEntityData -Type Organization -Repository $repo -Name "org"
$usersList = Get-VBOEntityData -Type User -Repository $repo | Where-Object {$_.Organization -eq $org}
$groupsList = Get-VBOEntityData -Type Group -Repository $repo | Where-Object {$_.Organization -eq $org}
$sitesList = Get-VBOEntityData -Type Site -Repository $repo | Where-Object {$_.Organization -eq $org}
# Remove all users
foreach ($user in $usersList) {
Write-Host "Removing user:" $user.DisplayName
Remove-VBOEntityData -Repository $repo -User $user -Mailbox -ArchiveMailbox -OneDrive -Sites -Confirm:$false
}
# Remove all groups
foreach ($group in $groupsList) {
Write-Host "Removing group:" $group.DisplayName
Remove-VBOEntityData -Repository $repo -Group $group -Mailbox -ArchiveMailbox -OneDrive -Sites -GroupMailbox -GroupSite -Confirm:$false
}
# Remove all sites
foreach ($site in $sitesList) {
Write-Host "Removing site:" $site.Title
Remove-VBOEntityData -Repository $repo -Site $site -Confirm:$false
}
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
GitHub: https://github.com/nielsengelen
-
- Influencer
- Posts: 14
- Liked: 1 time
- Joined: Apr 29, 2013 1:10 pm
- Contact:
Re: Delete oprhaned users
Thanks, your script works. However there is something preventing deletion:
"Remove-VBOEntityData : Cannot start the job: Remove user: Consulting.Calendar. Error: Organization cannot be deleted. Please disable
all jobs pointing to it first."
I tried to look for the job by Get-VBOJob, but there is no job listed for this organization. How can I find this job which is pointing to the item I want to delete?
"Remove-VBOEntityData : Cannot start the job: Remove user: Consulting.Calendar. Error: Organization cannot be deleted. Please disable
all jobs pointing to it first."
I tried to look for the job by Get-VBOJob, but there is no job listed for this organization. How can I find this job which is pointing to the item I want to delete?
-
- Product Manager
- Posts: 5796
- Liked: 1215 times
- Joined: Jul 15, 2013 11:09 am
- Full Name: Niels Engelen
- Contact:
Re: Delete oprhaned users
That doesn't sound right. If you don't see any jobs at all with Get-VBOJob -Org "ORGANIZATION", I suggest you open a support case for insight as there may be something in the database that is causing this issue.
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
GitHub: https://github.com/nielsengelen
-
- Lurker
- Posts: 2
- Liked: never
- Joined: Oct 15, 2020 9:41 am
- Contact:
Re: Delete oprhaned users
Im trying to get this one to work, but it does not set a $org variable.nielsengelen wrote: ↑Sep 29, 2020 12:30 pm The following should do it:Code: Select all
Import-Module "C:\Program Files\Veeam\Backup365\Veeam.Archiver.PowerShell\Veeam.Archiver.PowerShell.psd1" $repo = Get-VBORepository -Name "Default Backup Repository" # Change this to match your repository $org = Get-VBOEntityData -Type Organization -Repository $repo -Name "org" $usersList = Get-VBOEntityData -Type User -Repository $repo | Where-Object {$_.Organization -eq $org} $groupsList = Get-VBOEntityData -Type Group -Repository $repo | Where-Object {$_.Organization -eq $org} $sitesList = Get-VBOEntityData -Type Site -Repository $repo | Where-Object {$_.Organization -eq $org} # Remove all users foreach ($user in $usersList) { Write-Host "Removing user:" $user.DisplayName Remove-VBOEntityData -Repository $repo -User $user -Mailbox -ArchiveMailbox -OneDrive -Sites -Confirm:$false } # Remove all groups foreach ($group in $groupsList) { Write-Host "Removing group:" $group.DisplayName Remove-VBOEntityData -Repository $repo -Group $group -Mailbox -ArchiveMailbox -OneDrive -Sites -GroupMailbox -GroupSite -Confirm:$false } # Remove all sites foreach ($site in $sitesList) { Write-Host "Removing site:" $site.Title Remove-VBOEntityData -Repository $repo -Site $site -Confirm:$false }
I run: $org = Get-VBOEntityData -Type Organization -Repository $repo -Name "org"
If i then do "Write-host $org" it returns blank.
-
- Product Manager
- Posts: 5796
- Liked: 1215 times
- Joined: Jul 15, 2013 11:09 am
- Full Name: Niels Engelen
- Contact:
Re: Delete oprhaned users
And you changed "org" to your organization name?
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
GitHub: https://github.com/nielsengelen
Who is online
Users browsing this forum: No registered users and 19 guests