What do braces in property values mean?

This topic contains 6 replies, has 4 voices, and was last updated by Profile photo of Paul Jones Paul Jones 1 year, 2 months ago.

  • Author
    Posts
  • #29349
    Profile photo of Anthony Williams
    Anthony Williams
    Participant

    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 user@domain.edu | 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?

  • #29354
    Profile photo of Don Jones
    Don Jones
    Keymaster

    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.

  • #29355
    Profile photo of Curtis Smith
    Curtis Smith
    Participant

    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 curtis.smith@daltile.com | Select-Object -E
    xpandProperty Licenses
    

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

  • #29390
    Profile photo of Anthony Williams
    Anthony Williams
    Participant

    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 awilliams@domain.edu | Select-Object -ExpandProperty Licenses

    returns:

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

    But

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

    returns no results.

  • #29393
    Profile photo of Curtis Smith
    Curtis Smith
    Participant

    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"}
    
  • #29427
    Profile photo of Anthony Williams
    Anthony Williams
    Participant

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

  • #31542
    Profile photo of Paul Jones
    Paul Jones
    Participant

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

    Paul

You must be logged in to reply to this topic.