title: Trying to set user licenses in Office 365 via Powershell
body: <p>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.</p>
  
  <p>Here's what I've got:</p>
  
  <pre><code>$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}
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>Set-MsolUserLicense : User Not Found.  User: .
  </code></pre>
  
  <p>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: </p>
  
  <pre><code>$ENTERPRISEPACK=New-MsolLicenseOptions -AccountSkuId companyname:ENTERPRISEPACK -DisabledPlans "FLOW_0365_P2", "POWERAPPS_0365_P2"
  
  Set-MsolUserLicense -UserPrincipalName testuser.here@domain.com -LicenseOptions $ENTERPRISEPACK -Verbose
  </code></pre>
  
  <p>As you can see, the difference here is that I'm running it with one username entered specifically.</p>
  
  <p>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.</p>
  
  <p>Please help?</p>