Run PS script with scheduler Windows server 2008 RRS feed

  • Question

  • Hi, I need run PS script with load modules in Task Scheduler in Windows 2008 server.

    When run this file in Windows powershell modules window - it works. But Whne run this file in Windows powershell window is not working.



    Get-Module -ListAvailable | Where-Object {$_.Path -like "$PSHOME*"} | Import-Module 
    Get-MailboxStatistics -server EXCHANGE | Sort-Object TotalItemSize -Descending | convertto-html DisplayName,LastLogonTime,LastLogoffTime,ItemCount, StorageLimitStatus, @{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}} | set-content c:\scripts\CelkovaVelikostMailboxu.html

    Script has command for load modules! But in task scheduler script not working, no output.

    Thank you

    Tuesday, July 26, 2016 10:51 AM


  • Hi Josefyno,

    you are trying to access your Exchange, which cannot be imported using Import-Module.

    If it's an Exchange 2007, use this instead:

    Get-PSSnapin  "*Exchange*" -Registered | Add-PSSnapin

    If you are using Exchange 2010 or newer, use this script of mine.


    There's no place like

    Tuesday, July 26, 2016 12:06 PM