SCO 2012: PS Function for parsing the result of the “Run Exchange Management Shell Cmdlet” Activity

 

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:

 

use the function as shown here:

 

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

By | 2013-03-21T15:57:19+00:00 March 21st, 2013|Automation|5 Comments

About the Author:

Jakob Gottlieb Svendsen

Twitter: @JakobGSvendsen

Jakob Gottlieb Svendsen is a Microsoft Cloud and Data Center Management MVP (http://mvp.microsoft.com/en-us/default.aspx), Working as Global Lead Developer, Senior Consultant and Trainer at CTGlobal, where he is one of the driving forces in keeping CTGlobal a System Center Gold Partner and member of the System Center Alliance.

Since he started at Coretech in 2007, he has focused on Scripting and Development, primarily developing tools, extensions and scripts for the System Center Suite. His main area is Automation (including OMS/Azure Automation, Service Management Automation, PowerShell and Orchestrator). Another area is Windows Azure Pack / Azure Stack, where he does implementation, development, workshops and presentations. He is a world-wide renowned voice in the Automation field.

He is passionately devoted to the community, to which he contributes by being a moderator at TechNet and sharing his knowledge at http://blog.ctglobalservices.com/jgs

  • Co-founder: PowerShell User Group Denmark
  • Speaker at MMS 2016, Minneapolis (www.mmsmoa.com)
  • SCU Europe 2014, 2015, 2016 (www.systemcenteruniverse.ch)
  • Microsoft TechEd North America 2014, Houston
  • NIC 2012,2013,2014,2015, Oslo (www.nic.com)
  • Microsoft CampusDays 2011, 2013, Copenhagen
  • Microsoft TechDays 2015, Sweden (www.techdays.se)
  • Microsoft Partner Event: New in SC2012 SP1
  • User group meetings (PSUG.DK , SCUG.DK/BE/NO, AZMUG + more)
  • Microsoft Certified Trainer.
  • Microsoft Scripting Guys Forum Moderator

Main working areas:

  • Automation (Azure Automation, SMA, SCO)
  • Windows Azure Pack / Azure Stack
  • System CenterVisual Studio Team Services / Team Foundation Server
  • Development:C#.Net, VB.NET, VBScript, PowerShell, Service Manager, OpsMgr, ConfigMgr
  • Orchestrator
  • Windows Azure Pack / Azure Stack

Training:

  • Azure Automation
  • Service Management Automation
  • System Center Orchestrator
  • PowerShell, VBScript, C#.Net, VB.Net
  • Windows Azure Pack / Azure Stack Development Workshops

5 Comments

  1. Andy May 15, 2013 at 1:06 - Reply

    Hi,

    Thanks for the function but whenever I try to use it I get the following error:

    Method invocation failed because [System.Collections.ArrayList+ArrayListEnumeratorSimple] doesn’t contain a method named ‘Split’.

    I’m using a Powershell .net activity where I’m setting the output from the Exchange command (in this case get-mailboxpermission) to a variable then calling your function against that variable. My understanding is the problem is that the variable is not of a type that has a split method. I’ve tried prefixing the variable with [char] but it says it’s can’t convert the object. How should I be creating my variable using the output from the previous activities Exchange command to get it of an appropriate type?

    Thanks,
    Andy

  2. Vincent Leasum June 19, 2014 at 17:26 - Reply

    Hi, I really need to get this function working…. I’m learning powershell and Orchestrator, but I confess that I don’t understand how to use this function. could you post a screen shot of the whole runbook and pointing out where to use the function, how to invoke it, etc???

    thanks in advance.

Leave A Comment