Welcome Forums General PowerShell Q&A -Replace with the select-object

Viewing 3 reply threads
  • Author
    Posts
    • #174538
      Participant
      Topics: 4
      Replies: 54
      Points: 406
      Helping Hand
      Rank: Contributor

      Im trying to replace text within the select-object

      
      Get-MsolUser -all |Where-Object {$_.islicensed -eq $true} | Select-Object signinname,licenses,@{Name=”test”; E={(‘licenses’ -replace ‘{reseller-account:O365_’,”)}}
      

      This isnt working, anyone have a better solution ?

    • #174553
      Participant
      Topics: 2
      Replies: 1752
      Points: 3,621
      Helping Hand
      Rank: Community Hero

      You have to specify the property you want to use for the replacement.

      @{Name="test"; E={($_.licenses -replace '{reseller-account:O365_',")}

      … if I got it right 😉

    • #174556
      Participant
      Topics: 4
      Replies: 54
      Points: 406
      Helping Hand
      Rank: Contributor

      Almost 🙂

      now i get the following result

      Test@test.nl {reseller-account:O365_BUSINESS_PREMIUM} Microsoft.Online.Administration.UserLicense

      instead of

      Test@test.nl {reseller-account:O365_BUSINESS_PREMIUM}  BUSINESS_PREMIUM

       

    • #174562
      Participant
      Topics: 4
      Replies: 54
      Points: 406
      Helping Hand
      Rank: Contributor

      Well what a way for microsoft to put another array in there

       

      Get-MsolUser -all |Where-Object {$_.islicensed -eq $true} | Select-Object signinname,licenses,@{Name=”test”; E={($_.licenses.accountskuid -replace ‘reseller-account:O365_’,”)}}

      is the solution.

      Thanx @Olaf for pointing me in the right direction

Viewing 3 reply threads
  • The topic ‘-Replace with the select-object’ is closed to new replies.