locked
Putting a commas around my variable destroys output RRS feed

  • Question

  • why does this give me a legible format?

    $licinfo =  Get-MsolUser -UserPrincipalName "TSmith@lab.local" | Select-Object -ExpandProperty Licenses | Select-Object -ExpandProperty ServiceStatus 
    
    
    
    $licinfo
    
    
    ServicePlan            ProvisioningStatus
    -----------            ------------------
    SWAY                   PendingActivation 
    YAMMER_EDU             PendingInput      
    SHAREPOINTWAC_EDU      Success           
    SHAREPOINTSTANDARD_EDU Success           
    EXCHANGE_S_STANDARD    Disabled          
    OFFICESUBSCRIPTION     Disabled          
    MCOSTANDARD            Disabled  

    However adding commas makes it un readable?  Is there a way to make this work?

    Thanks

    $licinfo =  Get-MsolUser -UserPrincipalName "TSmith@lab.local" | Select-Object -ExpandProperty Licenses | Select-Object -ExpandProperty ServiceStatus 
    
    
    
    "$licinfo"
    
    
    Microsoft.Online.Administration.ServiceStatus Microsoft.Online.Administration.ServiceStatus Microsoft.Online.Administration.ServiceStatus Microsoft.Online.Administrat
    ion.ServiceStatus Microsoft.Online.Administration.ServiceStatus Microsoft.Online.Administration.ServiceStatus Microsoft.Online.Administration.ServiceStatus



    BTW my goal is to do logic that says
     if ($licinfo -match "SWAY                   PendingActivation" -and $licinfo -match "YAMMER_EDU             PendingInput") {"do something"} else {"Do something else"}

    Lishron


    • Edited by Lishron Monday, November 30, 2015 6:35 PM
    Monday, November 30, 2015 6:31 PM

Answers

  • My mistake I got it figured out. And I should have said quotes.

    Thank you

    PS this corrected the issue.

    Line 2 gave me a string to work with.

                       $licinfo =  Get-MsolUser -UserPrincipalName "$upn" | Select-Object -ExpandProperty Licenses | Select-Object -ExpandProperty ServiceStatus 
                       $lictext =   $licinfo | Out-String 


    Lishron

    • Marked as answer by Lishron Tuesday, December 1, 2015 12:37 PM
    Tuesday, December 1, 2015 12:37 PM

All replies

  • I'm not sure how to answer your question except to suggest that you need a primer on how PowerShell works with objects.

    Windows IT Pro - PowerShell: Objects and Output


    -- Bill Stewart [Bill_Stewart]

    Monday, November 30, 2015 6:58 PM
  • Where are the commas?  I see no commas.

    What is it that you are trying to do?  What is wrong wit the first example. It works as expected.


    \_(ツ)_/

    Monday, November 30, 2015 6:58 PM
  • My mistake I got it figured out. And I should have said quotes.

    Thank you

    PS this corrected the issue.

    Line 2 gave me a string to work with.

                       $licinfo =  Get-MsolUser -UserPrincipalName "$upn" | Select-Object -ExpandProperty Licenses | Select-Object -ExpandProperty ServiceStatus 
                       $lictext =   $licinfo | Out-String 


    Lishron

    • Marked as answer by Lishron Tuesday, December 1, 2015 12:37 PM
    Tuesday, December 1, 2015 12:37 PM
  • Your problem is the same as a great many people who never take the time to learn the basics of PowerShell.  THe illustration of that is how you ry to put quotes around everything.  This will cause you many issues until you spend time learning how this works.

    In your example you do this; "$upn".  Do not do this.  $upn does not need to be quoted.  Quoting many tings will have unpredictable results as you have just seen.  Only use quotes when you know why you are using them.


    \_(ツ)_/

    Tuesday, December 1, 2015 12:48 PM