speeding up things with jobs

This topic contains 2 replies, has 2 voices, and was last updated by Profile photo of turbo mcp turbo mcp 2 years ago.

  • Author
    Posts
  • #20707
    Profile photo of turbo mcp
    turbo mcp
    Participant

    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.....

  • #20711
    Profile photo of Don Jones
    Don Jones
    Keymaster

    You're passing something wacky to a command parameter. Specifically, $end contains something that isn't being loved.

    And, with your updates, I'm not clear what problem we're trying to solve. Would you maybe start a new post that provides some context and what you're asking for help with at this point?

  • #20712
    Profile photo of turbo mcp
    turbo mcp
    Participant

    yeah your right even I am confused at this point:)

    bottom line what I wanted to do is this:
    I have a script that works fine and what it does is it uses invoke-command to run get-messagetrackinglog on exchange servers to find stuff(like how many emails were sent in the last hour)
    so I have a foreach loop running invoke-command and all is good.

    I was trying to figure out away to make it even faster(instead of waiting for the loop to run on each of the servers)
    so workflow, I love them>>cant do it because of its own limitations
    then I thought either invoke-command -asjob or just jobs in general to accomplish my goal
    not sure what is the fastest way.

You must be logged in to reply to this topic.