none
getting @{ = } in the out put when using select-object RRS feed

  • Question

  • Hi, I am trying to get the list of Server Names of form everyday alerts which i receive in outlook and i am getting @{= ###} as the out put instead of only the server names.

    Also, i need the regex for format "XXXXXXXX###XXX" where First set of X = 8 Char, # = Number and last 3 characters will be same.

    Can someone help me out here.

    $outlook = new-object -com outlook.application;
    $ns = $outlook.GetNameSpace("MAPI");
    $inbox = $ns.Folders.Item('test@test.com').Folders.Item('Test')
    $messages = $inbox.items
    $totalemail = $messages.count
    write-host "Total Messages to process $totalemail"  -foregroundcolor green

    foreach($message in $messages)
    {
     $mbody = $message.Body #|ConvertFrom-Csv
    $search = $mbody | Select-String -Pattern "Server"  -AllMatches | select -First 1
    $server
    }

    Output:
    Total Messages to process 2
    @{ =Server001ORA}
    @{ =Server002ORA}

    Thanks,

    Saturday, February 14, 2015 12:38 AM

Answers

  • If that is what is being sent in the mail I think you are hosed up.

    Try this:
    $server | ($_ -split '=')[1] -replace '}'


    ¯\_(ツ)_/¯


    • Edited by jrv Saturday, February 14, 2015 1:31 AM
    • Marked as answer by Dinesh Kumar C Saturday, February 14, 2015 2:17 AM
    Saturday, February 14, 2015 1:29 AM

All replies

  • If that is what is being sent in the mail I think you are hosed up.

    Try this:
    $server | ($_ -split '=')[1] -replace '}'


    ¯\_(ツ)_/¯


    • Edited by jrv Saturday, February 14, 2015 1:31 AM
    • Marked as answer by Dinesh Kumar C Saturday, February 14, 2015 2:17 AM
    Saturday, February 14, 2015 1:29 AM
  • Hi Jvr,

    $server | ($_ -split '=')[1] -replace '}' is working.. :)

    The email doesn't have @{ = }, its only displayed in the output.

    Any help on the REGEX part?
    Saturday, February 14, 2015 2:02 AM