2

I'm trying to create an Exchange 2010 script that will search each transport server as a job. I try the following:

$transportserver = get-transportserver
foreach ($ts in $transportserver)
{
     $ts_name = $ts.name

     $s = New-PSSession -ComputerName $ts_name
     Invoke-Command -Session $s -Script { Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010; Get-MessageTrackingLog -server $args[0] } -Args $ts_name
}

But I get the error:

Value cannot be null. Parameter name: serverSettings
+ CategoryInfo          : NotSpecified: (:) [Get-MessageTrackingLog], ArgumentNullException
+ FullyQualifiedErrorId : 
     System.ArgumentNullException,Microsoft.Exchange.Management.TransportLogSearchTasks.GetMessageTrackingLog

I've tried a few variations like adding more parameters but it returns the same error.

2
  • Just to rule it out, is it possible that you're not running this against a Hub or Edge server?
    – squillman
    Oct 10, 2014 at 17:14
  • I'm both running it on and against Hub Transport servers.
    – smwk
    Oct 10, 2014 at 23:35

1 Answer 1

0

The script looks very simple, so i feel like your problem lays elsewhere. maybe try

invoke-command -computername $srv {Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010; Get-MessageTrackingLog}

If that fails maybe walk towards another solution, with psExec fx. This is just a quick copy/paste from my personal scripts.

$ps = new-object System.Diagnostics.Process
$ps.StartInfo.Filename = "O:\pstools\psexec.exe"

Foreach ($strComputer in $Servers)
{   
    $ps.StartInfo.Arguments = " \\" 
    $ps.StartInfo.Arguments += $strComputer.Name 
    $ps.StartInfo.Arguments += " gpupdate.exe /target:computer /force"
    $ps.start()
    $ps.WaitForExit()
}
1
  • You have to pass a parameter with the get-MessageTrackingLog so your first example returns an error. I can't use other executables so unfortunately the second example is not an option.
    – smwk
    Oct 15, 2014 at 12:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .