Aug 31 2020 02:28 PM - last edited on Feb 13 2023 03:44 PM by Meenah_Khosraw
Aug 31 2020 02:28 PM - last edited on Feb 13 2023 03:44 PM by Meenah_Khosraw
Hello there,
I'm not great with Powershell, and I've been trying to take my CSV of grad emails, and block the sign in, and remove the A3/A1 for student use licenses from the uses.
Is there a available script that I can use to do this, i cant seem to find one that works.
Sep 01 2020 02:20 PM - edited Sep 01 2020 02:26 PM
Hi @MarcW64
I have nothing to hand, but I've butchered a script I used last year to remove and readd licences for a bunch of students.
It should work, but try it on a single user to start off with.
$students = import-csv "C:\support\student_disable.csv" -delimiter ","
foreach ($student in $students)
{
$ObjectID=$student.ObjectID
$sku=$student.sku
Set-MsolUserLicense -ObjectID $ObjectID -RemoveLicenses $sku -Verbose
Set-MsolUser -ObjectID $ObjectID -BlockCredential $true
}
The csv looks like this:
If your csv has upn rather than ObjectID, then you can use the -UserPrincipalName switch instead of -objectid
Use Get-MsolAccountSku to get the correct licence name for your tenant.
Hope this helps,