Howdy Scripting Guys and Gals,
This is an Office 365 PowerShell Question. I'm trying to write a script that will only remove a single sku part from a user license. In other words, I have user that have both Exchange and SharePoint licenses. I want to remove the Exchange license but leave the SharePoint license, I have found a lot of information on removing all the entire SKU, but not just a single option. I been working with the -removelicense switch with no success. Example below:
Connect-MSOLService
$AccountSkuId = "fga:ENTERPRISEPACK"
$options = New-MsolLicenseOptions -AccountSkuId fga:ENTERPRISEPACK -DisabledPlans EXCHANGE_S_ENTERPRISE
$Users = Import-Csv C:\scripts\data\softmatch.csv
foreach($user in $users)
{
Set-MsolUserLicense -UserPrincipalName $user.UPN –RemoveLicenses fga:ENTERPRISEPACK -DisabledPlans EXCHANGE_S_ENTERPRISE
if($action.count -eq 0)
{
Write-Host -ForegroundColor Green "Removed licenses for" $user.UPN -ea silentlycontinue -ev +action-LicenseOptions $options
Write-output $user.UPN | Out-File c:\scripts\logs\EXLicenseRemoveSuccesslog.csv -Append
}
if($action.count -eq 1)
{
Write-Host -foreground Yellow "License removal failed for added for" $user.UPN
Write-Output $user.UPN | out-file c:\scripts\logs\EXLicenseRemovalFailurelog.csv -Append
}
Clear-Variable -Name action
}
Any suggestions?