I am trying to get the Exchange Database Status as well as the testing Outlook Web Services.
For getting the status of the existing Exchange databases, I have the following code :
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
. .\config.ps1
$body +=Get-MailboxDatabase | Get-MailboxDatabaseCopyStatus | sort @{expression='Status';Descending=$true},@{expression='name';ascending=$true} | ft name,status,contentindexstate | Out-string
Write-Output $body
where config.ps1 is my config file which contains the details of the exchange servers
Now, after this, I found the command to test Outlook web services which reads the following :
Test-OutlookWebServices -Identity:[email protected]
I wanted to try using a semicolon to chain commands in powershell. But unfortunately, I can't try it because my environment is not yet ready.
So, can I do it this way :
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
. .\config.ps1
$body +=Get-MailboxDatabase | Get-MailboxDatabaseCopyStatus | sort @{expression='Status';Descending=$true},@{expression='name';ascending=$true} | ft name,status,contentindexstate | Out-string; Test-OutlookWebServices -Identity:[email protected]
Write-Output $body
Is that the right way to do it? If not, How should I include the second command in the first to achieve this? I want both the results to be stored in $body and get printed.
$body +="-----------------------------Exchange Databases Status-------------------------------`r`n`r`n"Since you simply want to display it withWrite-Output$echo += "-----------------------------Exchange Databases Status-------------------------------rnrn" $echo += Get-Help Get-Help | Out-String $echo += Get-Command Get-Help | Out-String Write-Output $echo