Hi
im trying to speed up the results I get by running them as jobs on all of my servers(in this case its get-messagetracking command to track emails sent in last hour)
so I hope im doing this correct this is what my code looks like so far:
[blockquote]
$params = @{
end = $end
event= $event
ResultSize = ‘Unlimited’
server = $server
start= $start
}
$start=(Get-Date).addhours(-1).ToString()
$end=(Get-Date).ToString
$hubserver=‘server1’
$event= ‘send’
$Data = @()
The servers are processed
ForEach ($server in $hubservers){
$sb = [scriptblock]::create(“get-messagetrackinglog $(@params)”)
$init_sb = {add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010}
$data +=Start-Job -Name $server -ScriptBlock $sb -InitializationScript $init_sb
}
[/blockquote]
getting something like:
Get-Job |Receive-Job
Cannot bind parameter ‘End’. Cannot convert the "string ToString(), string ToString(string format), string ToString(System.IFormatProvider provider), string
ToString(string format, System.IFormatProvider provider), string IFormattable.ToString(string format, System.IFormatProvider formatProvider), string
IConvertible.ToString(System.IFormatProvider provider)" value of type “System.Management.Automation.PSMethod” to type “System.DateTime”.
+ CategoryInfo : InvalidArgument: (:) [Get-MessageTrackingLog], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.Exchange.Management.TransportLogSearchTasks.GetMessageTrackingLog
+ PSComputerName : localhost
once I settle this thing I ofcourse will add more servers and add a line to get all jobs and receive all the data from them(that’s basic idea atleast)
any help would be appreciated
Thanks
UPDATE:
I solved this error now im getting :
a positional parameter cannot be found that accepts argument ‘10:49:33’
UPDATE:
solved that too by putting ‘’ on date
I have a feeling that I am totally off here and not really running the job on the server:)
maybe I should go the route of:
$server| invoke-command -scriptblock {get-messagetrackinglog -resultssize unlimited -eventid “send” -start $start -end $end} -asjob
but then I get "parameter set cannot be resolved using the specified named parameters…