Maintain control of your Microsoft Office 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
Veeam Software
Posts: 3753
Liked: 741 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
}
https://foonet.be

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 1 guest