Maintain control of your Microsoft 365 data
Post Reply
Suzy
Novice
Posts: 5
Liked: never
Joined: Jan 23, 2020 3:21 pm
Contact:

removing licensed users with powershell

Post by Suzy »

We are trying to remove some licensed users before the 31 day period is up using a script we found at https://www.veeam.com/blog/remove-user- ... bo365.html

however we want to import the usernames and use a foreach loop such as this:

Import-csv licensedusers.csv

$repository = Get-VBORepository -Name "Sharepoint-All-Snapshot-Cloud to Cloud"

$Users = ForEach-Object
{
Get-VBOEntityData -Type User -Repository $repository -Name $_.User
}

Remove-VBOEntityData -Repository $repository -User $users -Mailbox -ArchiveMailbox -OneDrive -Sites

The script fails with :
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:\Users\Administrator\Documents\remove-licenseduser.ps1:7 char:52
+ Remove-VBOEntityData -Repository $repository -User $users -Mailbox -A ...
+ ~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Remove-VBOEntityData], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Veeam.Archiver.PowerShell.Cmdlets.BackupItems.RemoveVBOEntityData

Any ideas on how to fix this?
nielsengelen
Product Manager
Posts: 5619
Liked: 1177 times
Joined: Jul 15, 2013 11:09 am
Full Name: Niels Engelen
Contact:

Re: removing licensed users with powershell

Post by nielsengelen »

You can combine this faster (not tested but this should work):

Code: Select all

Import-Csv .\licensedusers.csv | ForEach-Object {
$user = Get-VBOEntityData -Type User -Repository $repository -Name $_.User
Remove-VBOEntityData -Repository $repository -User $user -Mailbox -ArchiveMailbox -OneDrive -Sites
}
Personal blog: https://foonet.be
GitHub: https://github.com/nielsengelen
Suzy
Novice
Posts: 5
Liked: never
Joined: Jan 23, 2020 3:21 pm
Contact:

Re: removing licensed users with powershell

Post by Suzy »

works like a charm,

Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests