Jump to content

Office 365 Bulk assign / unassign licences via powershell help


Recommended Posts

Posted

Hi

 

I have been trying to follow this tutorial

https://exitcodezero.wordpress.com/2013/03/13/how-to-bulk-assign-office-365-licenses-to-all-users/

 

But when I try run the final command I get the following error:

 

Get-MsolUser : A parameter cannot be found that matches parameter name 'results
ize'.
At line:1 char:34
+ $Users | Get-MsolUser -resultsize <<<<  unlimited
   + CategoryInfo          : InvalidArgument: ( [Get-MsolUser], ParameterBi
  ndingException
   + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.Online.Administ
  ration.Automation.GetUser

 

Any ideas on how to resolve it? Or know another way? I want to assign the same licence to all my users and unassign a different licence from all of them.

 

Thanks

Posted
Isn't it -All for MSol, -ResultSize is for things like Get-Mailbox I thought

Steve

 

Hi, I tried changing it to -All but now get the following message. Thanks

 

PS C:\Users\SWHS\Desktop> $Users | Get-MsolUser -All
Get-MsolUser : The input object cannot be bound to any parameters for the
command either because the command does not take pipeline input or the input
and its properties do not match any of the parameters that take pipeline input.
At line:1 char:10
+ $Users | Get-MsolUser -All
+          ~~~~~~~~~~~~~~~~~
   + CategoryInfo          : InvalidArgument: ( [Get-MsolUser], ParameterBi
  ndingException
   + FullyQualifiedErrorId : InputObjectNotBound,Microsoft.Online.Administrat
  ion.Automation.GetUser

Posted
That line should be $User = Get-msoluser -all

 

Looking over that persons code $user isn't defined anywhere so that first line should be setting it.

 

So would my command look like this?

$AccountSkuId = "llicenceName"
$UsageLocation = "GB"
$User = Get-MsolUser -All
$User | ForEach-Object {
Set-MsolUser -UserPrincipalName $_.UserPrincipalName -UsageLocation $UsageLocation
Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -AddLicenses $AccountSkuId
}

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...