Solved

Schedule an exchange shell task to clear log files

Posted on 2014-12-15
5
246 Views
Last Modified: 2015-01-05
I have a exchange shell script that I run manually to clear out a bunch of log files that are created by exchange which eats up storage space on our environment.

Unfortunately, I cannot get this to work as a scheduled task as it keeps failing. Can anyone guide me to help automate this?
0
Comment
Question by:MSSC_support
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 1

Expert Comment

by:Colin McDonald
ID: 40500045
Can you provide details of the error received when running the scheduled task?

Can you provide screen shots of task settings
0
 

Author Comment

by:MSSC_support
ID: 40500052
Ok.  At the moment I have it configured to run whether user is logged on or not and with highest privileges.

The program/script is set to:
C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe

and argument:

-NonInteractive -WindowStyle Hidden -command ". 'C:\Program Files\Microsoft\Exchange Server\V15\bin\RemoteExchange.ps1'; Connect-ExchangeServer -auto; 'C:\Purge Logs\Purge-LogFiles keep 7 days.ps1'"

The error message i get is 0x0.

Hope this helps.
0
 
LVL 82

Expert Comment

by:David Johnson, CD, MVP
ID: 40500136
a return of 0 normally means success, non zero means failure. Have you tried circular logging or getting an exchange aware backup
0
 
LVL 24

Accepted Solution

by:
VB ITS earned 500 total points
ID: 40500234
I use this line in a batch file to do the same thing, but for IIS logs. You can try this as opposed to using a PS script, works perfectly fine as a Scheduled Task:
forfiles /p "C:\logs" /m *.log /d -7 /C "cmd /c del @file"

Open in new window

Feel free to replace del @file  with echo @file to get a list of which files the script will delete. This is what I do when I want to test the batch file.
0
 

Author Closing Comment

by:MSSC_support
ID: 40531171
This works but is slightly more risky.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A recent project that involved parsing Tableau Desktop and Server log files to extract reusable user queries for use in other systems. I chose to use PowerShell to gather the data, and SharePoint to present it...
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
This tutorial will walk an individual through the process of configuring basic necessities in order to use the 2010 version of Data Protection Manager. These include storage, agents, and protection jobs. Launch Data Protection Manager from the deskt…
This video discusses moving either the default database or any database to a new volume.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question