Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Remote Exchange Powershell invoke command - customize return result

$
0
0

Hi

I am trying to create a powershell which connects to an exchange management shell and executes a command.

[scriptblock]$Command = {Get-MailboxDatabaseCopyStatus | select Name,ContentIndexState}

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://$Computername/powershell -Credential $Cred

Import-PSSession $Session

$Returnvalue = $Command.Invoke()
 
Remove-PSSession $Session

This would return a result like this:

Name              : DB02 - Specielle\EXCHANGE01
ContentIndexState : Healthy


Name              : DB01 - Standard\EXCHANGE01
ContentIndexState : Healthy

Now how do I create an if-sentence that would check if both are "Healthy" and then return "Echo "Healthy"", else if one is not healthy then return "Echo "Not Healthy""? (I dont need to specify which one that isn't healthy).

Best Regards,

Soren


Viewing all articles
Browse latest Browse all 21975

Trending Articles