none
Script Help Needed! RRS feed

  • Question

  • Hello,

    Im wondering if anyone can help me.  Im getting to grips with the basics of Powershell now but Im attempting to setup a little script that will assist me and the rest of our exchange administrators to pull back quick results from MessageTrackingLog instead of using the EMC Tracking tool of editing a command every time we want to do tracking.  The problem I have is that I wish to use most of the parameters available to the powershell cmdlet 'get-messagetrackinglog' via read-host -prompts.  But if you dont enter data in every one the script doesnt actually work. You just get an 'OK' response. You will see the couple of lines below that im trying to excempt from the requirement of data in the script.

    I will paste exactly where I am upto below to try and resolve the issue.  Any assistance is greatly appreciated.....

    [System.Windows.Forms.MessageBox]::Show("WELCOME TO MESSAGE TRACKING" , "EMAIL TRACKING")
    $server = Read-Host –Prompt ‘Enter Server Name to view Tracking Upon’
    $EventID = Read-Host –Prompt ‘Enter The EVENT ID'
    $Sender = Read-Host –Prompt ‘Enter The SMTP Address of the Sender Account’
    if ($sender -eq 'SEND')
    { Out-Host ""}
    else
    {}
    $Recipients = Read-Host –Prompt ‘Enter The SMTP Address of the Recipient Account’
    $MessageSubject = Read-Host –Prompt ‘Enter THE SUBJECT of the email you want to filter’
    if ($messagesubject -eq $null)
    { Out-Host ""}

    else
    {}    

    $StartDate = Read-Host –Prompt ‘Enter The Start Date for Message Tracking - FORMAT dd/mm/yyyy hh:mm:ss’
    $EndDate = Read-Host –Prompt ‘Enter The End Date for Message Tracking - FORMAT dd/mm/yyyy hh:mm:ss’

    Get-MessageTrackingLog -Server $server -EventID $EventID -Sender $sender -Recipients $recipients -MessageSubject $MessageSubject -Start $StartDate -End $EndDate | Select Timestamp, EventID, Sender, {$_.Recipients}, MessageSubject

    • Moved by Bill_Stewart Monday, July 7, 2014 6:55 PM Abandoned drive-by question
    Tuesday, March 25, 2014 2:05 PM

All replies

  • Hi SaviBry,

    you can probably catch most of this by doing a simple input-validation. Example:

    If ($server -eq ""){$Server = "*"}

    Cheers,
    Fred


    There's no place like 127.0.0.1

    Tuesday, March 25, 2014 2:41 PM