Maintain control of your Microsoft 365 data
Post Reply
josephc
Novice
Posts: 8
Liked: never
Joined: Apr 26, 2022 11:13 pm
Full Name: Joseph
Contact:

Remove selected user's OneDrive from repository

Post by josephc »

Case #05387608:
Can someone help me to remove OneDrive data from a thousand users in the repository? I'm trying to achive it using powershell command "ForEach" but unsuccessful. I believe it is simple if I will remove all Onedrive to all users but in my case I have a selected list of users only.
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 selected user's OneDrive from repository

Post by Mike Resseler » 1 person likes this post

jorgedlcruz
Veeam Software
Posts: 1372
Liked: 619 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Remove selected user's OneDrive from repository

Post by jorgedlcruz »

Hello Joseph,
As Mike said, I've attached a full script there, mind the part where you can select what to delete from the Users, Mailbox, OneDrive, etc.

Give it a try, and let us know.
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
josephc
Novice
Posts: 8
Liked: never
Joined: Apr 26, 2022 11:13 pm
Full Name: Joseph
Contact:

Re: Remove selected user's OneDrive from repository

Post by josephc »

Case #05387608
Hi Mike & Jorge,
Thanks in advance for sharing the script.
I tried it but I got an error. Please see below.

Code: Select all

++++++++++++++++++++++++++++++++++++++++++++++++++
PS C:\> $repository = Get-VBORepository -Name "S3 Repository"
PS C:\> $users = Import-Csv -Path C:\temp\test.csv
PS C:\> Foreach ($user in $users)
>> {
>> $user = Get-VBOEntityData -Type User -Repository $repository -name $users.DisplayName
>> Remove-VBOEntityData -Repository $repository -User $user -OneDrive -confirm:$false
>> }
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.GetVBOEntityData

Remove-VBOEntityData : Cannot bind parameter 'User'. Cannot convert the "@{DisplayName=Name Lastname;
Email=enail@domain.com}" value of type "System.Management.Automation.PSCustomObject" to type
"Veeam.Archiver.PowerShell.Cmdlets.DataManagement.VBOUserData".
At line:4 char:52
+ Remove-VBOEntityData -Repository $repository -User $user -OneDrive -c ...
+                                                    ~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Remove-VBOEntityData], ParameterBindingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Archiver.PowerShell.Cmdlets.BackupItems.RemoveVBOEn
   tityData
jorgedlcruz
Veeam Software
Posts: 1372
Liked: 619 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Remove selected user's OneDrive from repository

Post by jorgedlcruz »

Hello,
I have removed the sensible data from that user you tried.

Would you mind to share with us how does the CSV looks like, please?
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
josephc
Novice
Posts: 8
Liked: never
Joined: Apr 26, 2022 11:13 pm
Full Name: Joseph
Contact:

Re: Remove selected user's OneDrive from repository

Post by josephc »

Case #05387608
Hi Jorge,
Thanks for removing sensible data..
Here is the contents of my csv file;
++++++
DisplayName
Firstname1 Lastname1
Firstname2 Lastname2
jorgedlcruz
Veeam Software
Posts: 1372
Liked: 619 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Remove selected user's OneDrive from repository

Post by jorgedlcruz »

Hello,
Is that if you opened with a notepad?, I can not see the commas, or the expected format shared on the other thread

Code: Select all

DisplayName,Email
Jorge de la Cruz,jorge.delacruz@jorgedelacruz.es
Could you please try this format?

Thank you
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
josephc
Novice
Posts: 8
Liked: never
Joined: Apr 26, 2022 11:13 pm
Full Name: Joseph
Contact:

Re: Remove selected user's OneDrive from repository

Post by josephc »

Case #05387608

Hi Jorge,
This is exactly showing if I open it on notepad. I saved the file to a different csv but the result is the same.
+++++++

Code: Select all

DisplayName
User1 Lastname1
User2 Lastname2
jorgedlcruz
Veeam Software
Posts: 1372
Liked: 619 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Remove selected user's OneDrive from repository

Post by jorgedlcruz »

Can you please try the powershell commands without anything VB like the import, then write-output, so you see you have all correct, then a write-output inside the for each with the $users.DisplayName as said, no VB commands just normal powershell to see everything else is correct.

I guess the csv is on that c:\temp and all, let us know
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
josephc
Novice
Posts: 8
Liked: never
Joined: Apr 26, 2022 11:13 pm
Full Name: Joseph
Contact:

Re: Remove selected user's OneDrive from repository

Post by josephc »

It work with this command but using "ForEach" is not working.
+++++++++++++++++++++++++++++++++++

Code: Select all

$repo = get-vborepository -name "S3 Repository"
$user = get-vboentitydata -type user -repository $repo -name "Firstname Lastname"
remove-vboentitydata -repository $repo -user $user -OneDrive
josephc
Novice
Posts: 8
Liked: never
Joined: Apr 26, 2022 11:13 pm
Full Name: Joseph
Contact:

Re: Remove selected user's OneDrive from repository

Post by josephc »

I noticed that the script works if I put only one user on csv file but as soon as I added two or more users, I got that error message.

+++++++++++

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.GetVBOEntityData
jorgedlcruz
Veeam Software
Posts: 1372
Liked: 619 times
Joined: Jul 17, 2015 6:54 pm
Full Name: Jorge de la Cruz
Contact:

Re: Remove selected user's OneDrive from repository

Post by jorgedlcruz »

I am not sure what is wrong, perhaps the CSV, as I can not see it in your previous messages.

Tell me the output of this very simple Script:

Code: Select all

$users = Import-Csv -Path C:\users.csv
Foreach ($user in $users)
{
Write-Output $user.DisplayName
}
My CSV, in case it helps, looks like this, and yes it has commas:

Code: Select all

DisplayName,Email
Jorge de la Cruz,jorge.delacruz@jorgedelacruz.es
Second User,anotheremail@jorgedelacruz.es
Third User,anotheremail@domain.es
Let us know
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
josephc
Novice
Posts: 8
Liked: never
Joined: Apr 26, 2022 11:13 pm
Full Name: Joseph
Contact:

Re: Remove selected user's OneDrive from repository

Post by josephc »

Please see the result at the bottom;

PS C:\> Foreach ($user in $users)
>> {
>> Write-Output $user.DisplayName
>> }
Jorge de la Cruz
Second User
josephc
Novice
Posts: 8
Liked: never
Joined: Apr 26, 2022 11:13 pm
Full Name: Joseph
Contact:

Re: Remove selected user's OneDrive from repository

Post by josephc »

Jorge, I'm not sure if the problem was related to version of VEEAM Backup for Microsoft 365. I have the latest version 6.0.0.367.
cesar.becerra
Novice
Posts: 4
Liked: 1 time
Joined: Jan 16, 2023 11:12 pm
Full Name: Cesar Becerra
Contact:

Re: Remove selected user's OneDrive from repository

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@mydomain.com

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
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 16 guests