Comments

  1. Luca says

    Thanks Paul!!
    the script is really useful and saves me a lot of time during daily activity.
    Really a great job!!

  2. Marc says

    I am getting really frustrated the script via Task Scheduler.

    Environment:
    Windows 2008 R2
    Exchange 2010

    Problem >>
    I have two environments:
    Lab Environment: It works via Task Scheduler and when I run manually.
    Production Environment: Only if I run the scripts manually. Not via Task Scheduler.

    The user I am using on my production environment is a member of Domain Admins + Organization Management.
    If I log in the production environment I can run my scripts manually successfully.

    How my Task is configured:
    Run whether user is logged or not – checked
    Run with high privileges – checked

    Program/script: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe
    Argument: -Version 2.0 -NonInteractive -WindowsStyle Hidden -executionpolicy unrestricted -command “. ‘c:\Program Files\Microsoft\Exchange Server\v14\bin\RemoteExchange.ps1’; Connect-ExchangeServer -auto; c:\scripts\Test-ExchangeServerHealth.ps1 -Log -SendEmail”

    No matter what I do, the task seems to complete(according the history of the task – no erros whatsoever) but it does not send the report.

    Initially I thought was my SMTP server, but if I run the script manually works….like:
    .\Test-ExchangeServerHealth.ps1 -Log -SendEmail”

    I already ran:
    Set-ExecutionPolicy Unrestricted
    Set-ExecutionPolicy RemoteSigned
    No difference!

    If I run manually it works. The same happens with another script (Get-ExchangeEnvironmentReport). If I run manually it works. If I try to run via Task Scheduler, nothing happens.
    I reckon it is a permission issue. But to be honest I am running out of ideas.

    Any ideas?
    Please help ;-(

    • says

      My task scheduler argument is just:

      -command “C:\Scripts\ExchangeServerHealth\Test-ExchangeServerHealth.ps1 -Log -SendEmail”

      You don’t need to call remoteexchange.ps1 and connect-exchangeserver. The script handles that for you.

      Other than that, when in doubt just open a cmd.exe and paste in the full one-liner command you’re trying to run via Task Scheduler (eg powershell.exe -command “blah”) and see if that gives you any more clues.

      • Marc says

        Thanks Paul
        I managed to have it working using the following argument:

        -command “. ‘C:\Program Files\Microsoft\Exchange Server\V14\bin\RemoteExchange.ps1′; Connect-ExchangeServer -auto; c:\Scripts\Test-ExchangeServerHealth.ps1 -Log -SendEmail”

        I will leave like this now. :-)

  3. Phil Ready says

    Hi Paul
    Great script!
    I have been using with Exchange 2010. Do you have a updated version for Exchange 2013?

      • v-9basa says

        Hi Paul,

        Is there a script which will give us exchange resources report like disk size, quota usage per mailbox in percentage, transport data drive size, white space, no. of users per databse and these mailboxes who haven’t logged since 30 days or more, disabled mailboxes, most active mailboxes, and those mailboxes who are near to warning quota, and any other important exchange resources you can think of..thanks. I am using your scripts gat-daghealth and get-mailboxstatistcs scripts..thanks a lot for those scripts…..any inputs for my request

  4. Fahad says

    Hi Paul,

    In the above blog you mentioned you have updated the latest script version 1.2 but when we download the script it is 1.11 .
    Please give the link for latest version.

    I’m getting an error like below in version 1.11:
    Remove-PSSession cannot validate argument on parameter “ID”. The argument is Null. Provide a valid value for the argument, and then try running the command again.
    At C:\Program Files\….\test-exchangeserverhealth.ps1:422 Char:19

  5. Fahad says

    hey Paul

    I checked TechNet & github & only then I posted this comment. I apologize if i’m missing something here or if i’m over-looking something silly.

    This is a portion of the script which I downloaded from TechNet

    V1.10, 19/08/2014 – Fixed bug with E14 replication health not testing correct server.
    V1.11, 11/02/2015 – Added queue length to Transport queue result in report.
    V1.12, 5/03/2015 – Fixed bug with color-coding in report for Transport Queue length.
    V1.13, 7/03/2015 – Fixed bug with incorrect function name used sometimes when trying to call Write-LogFile
    #>

    #requires -version 2

    https://gallery.technet.microsoft.com/office/Generate-Health-Report-for-19f5fe5f

    Also, do u have any clue on the below error:

    I’m getting an error like below in version 1.11:
    Remove-PSSession cannot validate argument on parameter “ID”. The argument is Null. Provide a valid value for the argument, and then try running the command again.
    At C:\Program Files\….\test-exchangeserverhealth.ps1:422 Char:19

    Do I need to provide some variable value anywhere?
    My Mailflow test fails on windows server 2012 r2 but If I run it manually it works.

    Thanks
    Fahad

    • says

      There’s been a few reports of bugs with the mail flow test. To be honest it is somewhat of a hack to get it working in the first place with Exchange 2013. I haven’t been able to reproduce the bug in my own test environments which run CU7 so I’m no closer to finding a fix. I’m working on a replacement health check script for Exchange 2013 anyway that leverages more Managed Availability features rather than Test-* cmdlets, so this bug might never get fixed.

Leave a Reply

Your email address will not be published. Required fields are marked *