Question : Copying Echange Log Files

I am trying to Powershell to copy files older than 15 days to spare disk storage and then remove the logs once copied. I have got most of it but keep getting problems with a log file which is locked by exchange. I don't want to stop the exchnage services whilst I am doing this could someone help.
This is running on a remote server to the log files
Code Snippet:
1:
Get-childitem "\\exchhqcs01\d$\Program Files\Exchsrvr\MDBDATA\*.log" -recurse | ?{!$_.PSIsContainer -and ($_.LastWriteTime -lt (get-Date).adddays(-10))} | COPY-Item "\\emailserver\d$\Program Files\Exchsrvr\MDBDATA\" D:\Test
Open in New Window Select All

Answer : Copying Echange Log Files

From MS

You can't copy the message tracking logs from an Exchange server and then use the Get-MessageTrackingLog cmdlet or the Message Tracking tool to search the copied logs on a different Exchange server. Also, if you save an existing message tracking log, the change in the date-time stamp of the message tracking log file breaks the query logic that is used to search the message tracking logs.

See here to get round it (you do need to stop the services)

http://msexchangeteam.com/archive/2008/10/22/450009.aspx
Random Solutions  
 
programming4us programming4us