Author Posts

September 3, 2015 at 1:56 pm

We're using Office 365, and I need to convert all of our users from one license to another. But staff/faculty get one license while students get another, so I need to select all fac/staff and then change their license.

If I do:

Get-MsolUser -UserPrincipalName | FL

One of the properties is:

Licenses                               : {domain:STANDARDWOFFPACK_IW_FACULTY}

Which seems like a likely way to select only staff/faculty. But:

Get-MsolUser -all | Where  {_.Licenses -eq "{domain:STANDARDWOFFPACK_IW_FACULTY}"}

returns nothing. A user can have multiple licenses, so I tried -like and -contains as well, but no results. Am I misusing Where? Do the braces in the property value have a meaning I'm not allowing for?

September 3, 2015 at 2:01 pm

It means the property contains, or is designed to possibly contain, multiple items, and that's the best PowerShell can do to render that as text.

That means the contents of the property aren't simple values, necessarily, but potentially complex objects. -Contains can't easily test for that.

September 3, 2015 at 2:06 pm

Curly Braces on a property means that it is not a single value property. The property is multivalued. You can see that by getting one of your users and looking specifically at the license property.

Get-MsolUser -UserPrincipalName | Select-Object -E
xpandProperty Licenses

By doing that you will see that the license name is actually stored under the "AccountSkuID" property.

September 4, 2015 at 11:10 am

Thanks! I'm really enjoying learning the Powershell, but getting all the information on all the properties is frustrating.

I'm sorry to keep beating this horse, but it's still not giving me any results.

get-msoluser -UserPrincipalName | Select-Object -ExpandProperty Licenses


ExtensionData          : System.Runtime.Serialization.ExtensionDataObject
AccountSku             : Microsoft.Online.Administration.AccountSkuIdentifier
AccountSkuId           : domain:STANDARDWOFFPACK_IW_FACULTY


Get-MsolUser -all | Where {$_.AccountSkuID -eq "domain:STANDARDWOFFPACK_IW_FACULTY"}

returns no results.

September 4, 2015 at 2:04 pm

That's because AccountSkuID is a property of Licenses, which is a property of the MSOLUser. With the statement you have currently, it is looking for a property called AccountSkuID on your User Object, which does not exist. Your command should look like this:

Get-MsolUser -all | Where {$_.Licenses.AccountSkuID -eq "domain:STANDARDWOFFPACK_IW_FACULTY"}

September 7, 2015 at 6:49 am

Ah, I see. So I'm selecting a property of a property of a user object. Thanks!

October 30, 2015 at 10:51 pm

I was about to ask the exact same question about the exact same issue!
Thanks so much for the solution!