-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvertUserLicenses.ps1
29 lines (25 loc) · 1.05 KB
/
convertUserLicenses.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
set-psdebug -Strict
$sku1 = Get-MsolAccountSku | ? {$_.accountSkuId -match 'STANDARDWOFFPACK_IW_STUDENT'}
$skuId1 = $sku1.AccountSkuId
#$sku2 = Get-MsolAccountSku | ? {$_.accountSkuId -match 'OFFICESUBSCRIPTION_STUDENT'}
#$skuId2 = $sku2.AccountSkuId
$stuLicOpts = New-MsolLicenseOptions -AccountSkuId $studAdv.AccountSkuId -DisabledPlans YAMMER_EDU,SHAREPOINTWAC_EDU,SHAREPOINTSTANDARD_EDU,EXCHANGE_S_STANDARD,MCOSTANDARD
$users = @()
$users += Get-MsolUser -Synchronized -All
foreach ($u in $users) {
[bool] $convUser = $false
$lics = @()
$lics += $u.licenses
foreach ($l in $lics) {
if ($l.AccountSkuId -match 'STANDARDWOFFPACK_IW_STUDENT') {
Write-Host "User: " $u.UserPrincipalName "needs license conversion."
$convUser = $true
}
}
if ($convUser) {
Write-Host 'Attempting to change license options for user: ' $u.UserPrincipalName
$u | Set-MsolUserLicense -LicenseOptions $stuLicOpts -ErrorAction Continue
Write-Host 'Hurray!'
Write-Host ''
}
}