Maintain control of your Microsoft 365 data
Post Reply
vjalalv
Novice
Posts: 3
Liked: 1 time
Joined: Apr 05, 2022 8:50 am
Full Name: Mohamed Jalal
Contact:

Remove repo data for specific users

Post by vjalalv »

Hi ,

I am newbie in VBO. Please help me to fix the below script which returns error .
Trying to remove data of specific list of users from repository to remove their licenses.

Code: Select all

$repository = Get-VBORepository -Name "Veeam Repo"
$users = Import-Csv -Path C:\scripts\users_bulk.csv 
Foreach ($user in $users)
{
$user = Get-VBOEntityData -Type User -Repository $repository -Name $_.DisplayName
Remove-VBOEntityData -Repository $repository -User $user -Mailbox -ArchiveMailbox -OneDrive -Sites -confirm:$false
}
Thanks
vjalalv
Mike Resseler
Product Manager
Posts: 8045
Liked: 1263 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

Re: Remove repo data for specific users

Post by Mike Resseler »

Hi vjalalv,

Can you let us know what error you get?

Thanks
Mike
vjalalv
Novice
Posts: 3
Liked: 1 time
Joined: Apr 05, 2022 8:50 am
Full Name: Mohamed Jalal
Contact:

Re: Remove repo data for specific users

Post by vjalalv »

Hi Mike,

Thanks for your response. script returns below error,

Code: Select all

Remove-VBOEntityData : Cannot convert 'System.Object[]' to the type
'Veeam.Archiver.PowerShell.Cmdlets.DataManagement.VBOUserData' required by parameter 'User'. Specified method is not
supported.
At C:\scripts\wipe_repo_data.ps1:6 char:52
+ Remove-VBOEntityData -Repository $repository -User $user -Mailbox -Ar ...
+                                                    ~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Remove-VBOEntityData], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Veeam.Archiver.PowerShell.Cmdlets.BackupItems.RemoveVBOEntityData

Remove-VBOEntityData : Cannot convert 'System.Object[]' to the type
'Veeam.Archiver.PowerShell.Cmdlets.DataManagement.VBOUserData' required by parameter 'User'. Specified method is not
supported.
At C:\scripts\wipe_repo_data.ps1:6 char:52
+ Remove-VBOEntityData -Repository $repository -User $user -Mailbox -Ar ...
+                                                    ~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Remove-VBOEntityData], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgument,Veeam.Archiver.PowerShell.Cmdlets.BackupItems.RemoveVBOEntityData
Thanks
vjalalv
nielsengelen
Product Manager
Posts: 5635
Liked: 1181 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: Remove repo data for specific users

Post by nielsengelen »

Can you provide more details about how your CSV looks like?
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
jorgedlcruz
Veeam Software
Posts: 1363
Liked: 615 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Remove repo data for specific users

Post by jorgedlcruz »

Hello,
I just tried it on my lab, and your commands look perfect to me, I was struggling for a few minutes as my excel for some reason was exporting a CSV with ; instead of the normal ,

Once figured out that, this worked for me with no issue:

Code: Select all

$repository = Get-VBORepository -Name "REPO-LOCAL-1Y"
$users = Import-Csv -Path C:\scripts\users_bulk.csv
Foreach ($user in $users)
{
$user = Get-VBOEntityData -Type User -Repository $repository -Name $users.DisplayName
Remove-VBOEntityData -Repository $repository -User $user -Mailbox -ArchiveMailbox -OneDrive -Sites -confirm:$false
}
My CSV had just one chap, so the result was this:

Code: Select all

Id                                   JobId                                JobName                       CreationTime
--                                   -----                                -------                       ------------
3b6c599e-8936-4c59-ab19-bf5fccb4c340 2bd5651e-e5e1-4561-a4b5-7b85cf0201f5 Remove user: Jorge de la Cruz 4/20/2022 10...
My CSV looked like this:

Code: Select all

DisplayName,Email
Jorge de la Cruz,jorge.delacruz@jorgedelacruz.es
As Niels asked, please share how does it look like yours, omit real names, or emails, etc.
Jorge de la Cruz
Senior Product Manager | Veeam ONE @ Veeam Software

@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2024 / InfluxAce / Grafana Champion
vjalalv
Novice
Posts: 3
Liked: 1 time
Joined: Apr 05, 2022 8:50 am
Full Name: Mohamed Jalal
Contact:

Re: Remove repo data for specific users

Post by vjalalv » 1 person likes this post

My csv had only one column with display names but the header "DisplayName" was not present which caused error.
It worked after I added it.

Thanks @ Niels and @jorgedlcruz .
jorgedlcruz
Veeam Software
Posts: 1363
Liked: 615 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Remove repo data for specific users

Post by jorgedlcruz »

Thank you, Mohamed, for coming back to us. Glad it works now.
Jorge de la Cruz
Senior Product Manager | Veeam ONE @ Veeam Software

@jorgedlcruz
https://www.jorgedelacruz.es / https://jorgedelacruz.uk
vExpert 2014-2024 / InfluxAce / Grafana Champion
cesar.becerra
Novice
Posts: 4
Liked: 1 time
Joined: Jan 16, 2023 11:12 pm
Full Name: Cesar Becerra
Contact:

Re: Remove repo data for specific users

Post by cesar.becerra »

Hello,
I have the same problem, the script works just putting a single line in the csv:

DisplayName,Email
Javier Rugeles,jrugeles@belcorp.biz

If I add a second user I get an error:

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
Babegeatty
Lurker
Posts: 2
Liked: never
Joined: Feb 10, 2023 2:09 am
Full Name: Gabriel J B
Contact:

Re: Remove repo data for specific users

Post by Babegeatty »

Firstly, big thanks to OP. You're a legend.

cesar.becerra, I was having the same issue but resolved it by adding a counter. The loop isn't working as it should. Below is the amended code:

Code: Select all

$repository = Get-VBORepository -Name "ClientX"
$users = Import-Csv -Path C:\scripts\users_bulk.csv
$counter = 0

Foreach ($user in $users)
{
$user = Get-VBOEntityData -Type User -Repository $repository -Name $user.DisplayName
Remove-VBOEntityData -Repository $repository -User $user -Mailbox -ArchiveMailbox -OneDrive -Sites -confirm:$false
$counter++
if($counter -eq $users.Count){break}
}
This will continue the loop to collect all users in the CSV.

Remembering that this will only remove the repository data. You will still need to run the below code to remove the licenses for that org:

Code: Select all

$org = Get-VBOOrganization -Name "ClientX.onmicrosoft.com"
$licensedUser = Get-VBOLicensedUser -Organization $org
Remove-VBOLicensedUser -User $licensedUser
Hope this helps :)
Mike Resseler
Product Manager
Posts: 8045
Liked: 1263 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

Re: Remove repo data for specific users

Post by Mike Resseler »

Thanks! Make sure you post this also here: https://community.veeam.com/ for additional visibility ;-)
Babegeatty
Lurker
Posts: 2
Liked: never
Joined: Feb 10, 2023 2:09 am
Full Name: Gabriel J B
Contact:

Re: Remove repo data for specific users

Post by Babegeatty »

Amended my license removing script. Old script only did the first user in the org.

Code: Select all

$org = Get-VBOOrganization -Name "ClientX.onmicrosoft.com"
$licensedUser = Get-VBOLicensedUser -Organization $org
foreach ($user in $licensedUser) {
  Remove-VBOLicensedUser -User $user
}
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests