-Replace with the select-object

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

This topic contains 3 replies, has 2 voices, and was last updated by

 
Participant
2 weeks, 2 days ago.

  • Author
    Posts
  • #174538

    Participant
    Topics: 4
    Replies: 54
    Points: 382
    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: 1
    Replies: 1529
    Points: 2,587
    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: 382
    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: 382
    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

You must be logged in to reply to this topic.