SAM: 5.2.0 with Hotfix 1
Exchange: 2010 with Update Rollup 4-v2 for Exchange Server 2010 Service Pack 2 (KB2756485)
NPM: 10.3.1
The below script used to work when running remotely with SAM against Exchange 2007 but with 2010 it throws an error
"Get-Queue : Value cannot be null. Parameter name: serverSettings At line:7 char:18 + $mapi = Get-Queue <<<< -Server $server | Where-Object {$_.DeliveryType -like "MapiDelivery"} | Select-Object -ExpandProperty MessageCount | Measure-Object -Sum | Select-Object -ExpandProperty Sum + CategoryInfo : NotSpecified: (:) [Get-Queue], ArgumentNullException + FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Exchange.Management.QueueViewerTasks.GetQueueInfo Get-Queue : Value cannot be null. Parameter name: serverSettings At line:12 char:19 + $smart = Get-Queue <<<< -Server $server | Where-Object {$_.DeliveryType -like "SmartHostConnectorDelivery"} | Select-Object -ExpandProperty MessageCount | Measure-Object -Sum | Select-Object -ExpandProperty Sum + CategoryInfo : NotSpecified: (:) [Get-Queue], ArgumentNullException + FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Exchange.Management.QueueViewerTasks.GetQueueInfo Get-Queue : Value cannot be null. Parameter name: serverSettings At line:17 char:19 + $other = Get-Queue <<<< -Server $server | Where-Object {($_.DeliveryType -notlike "MapiDelivery") -and ($_.DeliveryType -notlike "SmartHostConnectorDelivery")} | Select-Object -ExpandProperty MessageCount | Measure-Object -Sum | Select-Object -ExpandProperty Sum + CategoryInfo : NotSpecified: (:) [Get-Queue], ArgumentNullException + FullyQualifiedErrorId : System.ArgumentNullException,Microsoft.Exchange.Management.QueueViewerTasks.GetQueueInfo"
which we believe is a problem with Exchange 2010. In the below code if we replace "$Server" with the Fully Qualified Domain Name (FQDN) and we change the script to run locally it works perfectly. Unless someone has an answer to the above error my questions is how can I use the FQDN of the server I'm monitoring in the below script. I know I can use $(IP) to get the IP address of the host Solarwinds is monitoring but that doesn't work so I need the FQDN. I could add code to get the FQDN from the IP address but if there is an easier way using something built in to Solarwinds that would be preferred. I have also use both x86 and x64.
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
$names = [System.Net.NetworkInformation.IPGlobalProperties]::GetIPGlobalProperties()
$fqdn = "{0}.{1}" -f $names.HostName, $names.DomainName
$server = $fqdn
$mapi = Get-Queue -Server $server | Where-Object {$_.DeliveryType -like "MapiDelivery"} | Select-Object -ExpandProperty MessageCount | Measure-Object -Sum | Select-Object -ExpandProperty Sum
Write-Host "Message.1: Total Items in the Mapi Delivery Queue"
Write-Host "Statistic.1: $mapi"
$smart = Get-Queue -Server $server | Where-Object {$_.DeliveryType -like "SmartHostConnectorDelivery"} | Select-Object -ExpandProperty MessageCount | Measure-Object -Sum | Select-Object -ExpandProperty Sum
Write-Host "Message.2: Total Items in the SmartHost Delivery Queue"
Write-Host "Statistic.2: $smart"
$other = Get-Queue -Server $server | Where-Object {($_.DeliveryType -notlike "MapiDelivery") -and ($_.DeliveryType -notlike "SmartHostConnectorDelivery")} | Select-Object -ExpandProperty MessageCount | Measure-Object -Sum | Select-Object -ExpandProperty Sum
Write-Host "Message.3: Total Items in the Other Mail Queues"
Write-Host "Statistic.3: $other"