Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources: Active Threads
Viewing all articles
Browse latest Browse all 8411

Get all users with job title "XYZ" and assign license with options "ABC"

$
0
0

Hello All

We are in the process of a mass migration from on premise to O365, and as part of that I have the lovely task of assigning the licenses. As this is a phased roll out we are currently only assigning licenses to managers (approx. 360) 

I had started doing this using the web portal - but realised there's not enough years left of my life to get it done.. 

Coming from a .Net background I thought this would be straight forward enough - however it seems to have me stumped..

Here's what I have so far:

If ($Session -eq $null) {

    $Cred = Get-Credential
    $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.outlook.com/powershell -Credential $Cred -Authentication Basic -AllowRedirection
    $ImportResults = Import-PSSession $Session
    Import-Module MSOnline
    Connect-MSOLService -Credential $Cred }
Set-MsolUserLicense -UserPrincipalName "User@blah.co.uk" -AddLicenses "balh:ENTERPRISEWITHSCAL"
$DisabledOptions = @()
$DisabledOptions += "EXCHANGE_S_ENTERPRISE"
$DisabledOptions += "RMS_S_ENTERPRISE"
$DisabledOptions += "OFFICESUBSCRIPTION"
$DisabledOptions += "MCOSTANDARD"
$DisabledOptions += "MCOVOICECONF"
$DisabledOptions += "RMS_S_ENTERPRISE"
$DisabledOptions += "SHAREPOINTWAC"
$LicenseOptions = New-MsolLicenseOptions -AccountSkuId "blah:ENTERPRISEWITHSCAL" -DisabledPlans $DisabledOptions

Set-MsolUserLicense -User "user@blah.co.uk" -LicenseOptions $LicenseOptions 

Firstly - it seems strange to me that I have to assign all licenses, then strip back the ones I don't want the user to have. (Or am I doing this wrong) 

Secondly - ideally - I would like to run this for all users with the word 'manager' in their job title.. Is this possible?


I have tried get-msoluser -title "Manager" & get-msoluser -title "*Manager*" etc but it seems to ignore wildcards..?

I am actually building a GUI to manage our users as part of another project, and plan on having it run PS commands - so if it can't be done with powershell, I will have to wait till that's ready to use.

Any help would be appreciated - please accept my apologies if something similar has already been covered, I tried to search - but not overly sure what to search for.

Thanks

Mike Hudson


Viewing all articles
Browse latest Browse all 8411

Latest Images

Trending Articles



Latest Images