none
Parse results of a cmdlet RRS feed

  • Question

  • When running get-mailboxfolderstatistics identity returns something like this:

    Identity
    domain.org/OU/OU/OU/UserName\Inbox\
    domain.org/OU/OU/OU/UserName\Inbox\2010
    domain.org/OU/OU/OU/UserName\Inbox\CurrentProjects

    Is it possible to regex the output of identity to only display the Username?  Or, display nothing after the username?

    I know I can combine cmdlets to get the displayname from get-mailbox but I wanted to see if this is possible.

    Sunday, February 7, 2016 6:39 PM

Answers

  • get-mailbox jsmith |
         Get-MailboxFolderStatistics -FolderScope inbox |
         select @{n='username';e={(($_.Identity -split '\\')[0] -split '/')[-1]}}


    \_(ツ)_/

    • Marked as answer by The_Messenger Monday, February 8, 2016 1:23 PM
    Sunday, February 7, 2016 7:44 PM

All replies

  • get-mailbox jsmith |
         Get-MailboxFolderStatistics -FolderScope inbox |
         select @{n='username';e={(($_.Identity -split '\\')[0] -split '/')[-1]}}


    \_(ツ)_/

    • Marked as answer by The_Messenger Monday, February 8, 2016 1:23 PM
    Sunday, February 7, 2016 7:44 PM
  • Thanks jrv!! Exactly what I need.

    Can you explain the split syntax?

    Monday, February 8, 2016 1:23 PM
  • Help about_operators
    help about_Split

    \_(ツ)_/

    Monday, February 8, 2016 2:13 PM