Office 365 requires the user's usage location to determine which service are available to them. Thus, UsageLocation
is a property of a user, which can be set with the -UsageLocation
parameter of Set-MsolUser
or New-MsolUser
:
Set-MsolUser -UserPrincipalName bob@contoso.com -UsageLocation "US";
Once you've set the user's UserLocation
, you should be able to assign licenses to that user.
If the usage location is the same for all your users, you can include it directly in you ForEach-Object
loop:
Import-CSV -Path sapusers_sample.csv | ForEach-Object {
Set-MsolUser -UserPrincipalName $_.UserPrincipalName `
-UsageLocation "US";
Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName `
-AddLicenses wcs1:STANDARDWOFFPACK `
-LicenseOptions $options;
}
You could also just as easily add a "UsageLocation" column to the input CSV:
Import-CSV -Path sapusers_sample.csv | ForEach-Object {
Set-MsolUser -UserPrincipalName $_.UserPrincipalName `
-UsageLocation $_.UsageLocation;
Set-MsolUserLicense -UserPrincipalName $_.UserPrincipalName `
-AddLicenses wcs1:STANDARDWOFFPACK `
-LicenseOptions $options;
}