What do braces in property values mean?

Welcome Forums General PowerShell Q&A What do braces in property values mean?

Viewing 6 reply threads
  • Author
    Posts
    • #29349
      Participant
      Topics: 3
      Replies: 7
      Points: 0
      Rank: Member

      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
      Keymaster
      Topics: 13
      Replies: 4872
      Points: 1,844
      Helping HandTeam Member
      Rank: Community Hero

      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
      Participant
      Topics: 6
      Replies: 656
      Points: 35
      Rank: Member

      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
      Participant
      Topics: 3
      Replies: 7
      Points: 0
      Rank: Member

      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
      Participant
      Topics: 6
      Replies: 656
      Points: 35
      Rank: Member

      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
      Participant
      Topics: 3
      Replies: 7
      Points: 0
      Rank: Member

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

    • #31542
      Participant
      Topics: 0
      Replies: 1
      Points: 0
      Rank: Member

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

      Paul

Viewing 6 reply threads
  • The topic ‘What do braces in property values mean?’ is closed to new replies.

One thought on “What do braces in property values mean?

  1. Pingback: Searching Multi-Valued Properties in PowerShell - Adam Fowler - I.T. From Australia

Comments are closed.