Page 1 of 1

Executing Exchange PowerShell command in multiple servers and send the result to email?

Posted: Wed Jul 25, 2018 12:39 am
by ITEngineer
How can this code below modified so it can be run or executed for all Exchange servers rather than the current run session only?

Code: Select all

$session = New-PSSession -Configurationname Microsoft.Exchange -ConnectionURI http://PRDMAIL01-VM/PowerShell/ -Authentication Kerberos
[void] (Import-PSSession $session -AllowClobber)

$ExcServers = (Get-TransportService)
$ExcServers | ForEach-Object {Get-Queue -Server $_.Server} |
		Where-Object {($_.MessageCount -gt 0) -and ($_.Identity -notlike "*\Poison") -and ($_.Identity -notlike"*\Shadow\*")} |
		Select-Object Identity, Status, MessageCount, NextHopDomain, LastError | ft -AutoSize
So far it can only grab the email queue from PRDMAIL01-VM, but not the other 7 servers where I have in the Datacenter?

If possible, how can the result is emailed?

Thanks in advance.

Re: Executing Exchange PowerShell command in multiple servers and send the result to email?

Posted: Wed Jul 25, 2018 12:59 am
by jvierra