Maintain control of your Microsoft 365 data
Post Reply
cesar.becerra
Novice
Posts: 4
Liked: 1 time
Joined: Jan 16, 2023 11:12 pm
Full Name: Cesar Becerra
Contact:

Error deleting multiple mailbox users in Veeam O365

Post by cesar.becerra »

Hello,
I have a problem, I need to delete mailbox jobs with more than 200 users backed up in Veeam O365, it's simple to use power shell to delete a single repository user. But when trying to add a csv to bulk delete I get an error.

This is the script I'm trying to use:

Code: Select all

$repository = Get-VBORepository -Name "My Repository"
$users = Import-Csv -Path D:\csv\users.csv
Foreach ($user in $users)
{
$user = Get-VBOEntityData -Type User -Repository $repository -Name $users.DisplayName
Remove-VBOEntityData -Repository $repository -User $user -Mailbox -ArchiveMailbox -confirm:$false
}
The script works fine only when it is one line in the csv:

Code: Select all

DisplayName,Email
Javier Rugeles,jrugeles@mydomain.com
If I add a second user I get an error:

Code: Select all

Get-VBOEntityData : Cannot convert 'System.Object[]' to the type 'System.String' required by parameter 'Name'.
Specified method is not supported.
At line:3 char:68
+ ... ntityData -Type User -Repository $repository -Name $users.DisplayName
+ ~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-VBOEntityData], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Veeam.Archiver.PowerShell.Cmdlets.DataManagement.GetVBOEnt
I opened the case with veeam but they tell me that they do not manage custom scripts Case #05823836
Mildur
Product Manager
Posts: 8735
Liked: 2296 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: Error deleting multiple mailbox users in Veeam O365

Post by Mildur » 1 person likes this post

Hi

Found the issue. In the loop there was $users.DisplayName. But it should be $user.DisplayName.
With users, the command gets the entire array instead of only one user. We only need the currently processed display name (string) instead of the entire array.

Code: Select all

$repository = Get-VBORepository -Name "My Repository"
$users = Import-Csv -Path D:\csv\users.csv
Foreach ($user in $users)
    {
        $user = Get-VBOEntityData -Type User -Repository $repository -Name $user.DisplayName
        Remove-VBOEntityData -Repository $repository -User $user -Mailbox -ArchiveMailbox -confirm:$false
}
I will delete the double post in the other topic.

best,
Fabian
Product Management Analyst @ Veeam Software
cesar.becerra
Novice
Posts: 4
Liked: 1 time
Joined: Jan 16, 2023 11:12 pm
Full Name: Cesar Becerra
Contact:

Re: Error deleting multiple mailbox users in Veeam O365

Post by cesar.becerra » 1 person likes this post

Hello Fabian,

Perfect! With this simple change it is already possible to see the progressive elimination of each required user.
Thanks for the support! :D
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests