Created
August 19, 2020 23:46
-
-
Save sob/fe44d2e7d128ef99171eebe7dfe59198 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$freshmen = Get-AzureADUser -All $true | Where-Object {$_.Mail -like '*2024@my.corpuschristisaints.org'} | |
$freshmen | ForEach-Object { | |
Write-Host "Removing User " $_.UserPrincipalName "..." | |
Write-Host -NoNewline -ForegroundColor DarkGreen "- Removing Licenses " | |
$licenses = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses | |
$licenses.AddLicenses = @() | |
$licenses.RemoveLicenses = (Get-AzureADSubscribedSku | Where-Object -Property SkuPartNumber -Value "M365EDU_A3_STUUSEBNFT" -EQ).SkuID | |
Set-AzureADUserLicense -ObjectId $_.UserPrincipalName -AssignedLicenses $licenses | |
Write-Host -ForegroundColor Green " done!" | |
Write-Host -NoNewLine -ForegroundColor DarkGreen "- Removing User" | |
Write-Host -ForegroundColor Green " done!" | |
Write-Host | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment