I have an Office 365 tenant with multiple license plans and I'm trying to disable certain features of the E3 plan in bulk via Powershell.
Here's what I've got:
$ENTERPRISEPACK=New-MsolLicenseOptions -AccountSkuId companyname:ENTERPRISEPACK -DisabledPlans "FLOW_0365_P2", "POWERAPPS_0365_P2"
Import-CSV c:\scripts\inputfiles\e3users.csv | foreach-object -process { Set-MsolUserLicense -UserPrincipalName $_.upn -LicenseOptions $ENTERPRISEPACK -Verbose}
The issue that I'm running into, is that I can verify the users exist, and import the CSV as valid, but I get an error for every user in my CSV:
Set-MsolUserLicense : User Not Found. User: .
This is pretty frustrating, as I only want to disable the features for all E3 users (which would be in my CSV) and this command works when you run it as:
$ENTERPRISEPACK=New-MsolLicenseOptions -AccountSkuId companyname:ENTERPRISEPACK -DisabledPlans "FLOW_0365_P2", "POWERAPPS_0365_P2"
Set-MsolUserLicense -UserPrincipalName [email protected] -LicenseOptions $ENTERPRISEPACK -Verbose
As you can see, the difference here is that I'm running it with one username entered specifically.
It just makes sense to me that I'd be able to pipe it input and run through a loop, but I'm missing something.
Please help?