If you are using the Exchange Admin Integration Pack. You might have tried to use the run exchange shell cmdlet” activity and disocvered that the result is kind special in formatting.

 

Your result will look similar to this:

[PSComputerName: ex2010.cloud.local]
[RunspaceId: f30b4063-2b50-4609-9f84-91a480ac4bea]
[Database: Mailbox Database 1872261918]
[UseDatabaseRetentionDefaults: True]
[RetainDeletedItemsUntilBackup: False]

to help you , i have created a function for powershell that does it job:

function ConvertTo-ExchangeOutputCollection ([String] $inputText = @(throw "Error No Input Text supplied"))
{

    $returnCollection = @{}
    $keypairCollection = $inputText.Split("`n")
    foreach ($keypair in $keypairCollection)
    {
        $trimmedKeyPair = $keypair.Trim().TrimStart("[").TrimEnd("]")
        $splitPosition = $trimmedKeyPair.IndexOf(":")
        $propertyName = $trimmedKeyPair.Substring(0,$splitPosition).Trim()
        $propteryValue = $trimmedKeyPair.Substring($splitPosition + 2).Trim()
        $returnCollection += @{ $propertyName =  $propteryValue }
     }
    $returnCollection

}

 

use the function as shown here:

$result= ConvertTo-ExchangeOutputCollection $inputText
$database = $result.Database

 

The function created a key/pair collection containing all parts of the result, you then use the standard dot or [] syntax to get the value from the collection into a single simple string variable.

then get map the variable to published data as seen in this screenshot:

image

 

Update 15/05/2013: added [String] in parameter to make sure the input is in the right format. Thank you for reminding me Andy