Hello Experts,
I need to remove the licenses from my o365 users nightly. (I'll tell why if asked.)
I was trying to use this:
$x = Get-MsolUser -All | where {$_.isLicensed -eq $true}; $x | foreach {Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName -RemoveLicenses "tenant:PROJECTCLIENT_GOV"}
Which should work, but looks ugly failing on 700 accounts and succeeding on the 35 that actually have licenses.
How can I change this statement to return only account licensed to use tenant:PROJECTCLIENT_GOV?
Thanks,
Keith