Link to home
Start Free TrialLog in
Avatar of sglee
sglee

asked on

Keep Log folder in Exchange 2010

User generated imageUser generated imageHi,
 I have SBS2011/Exchange 2010 and am doing some clean up in OS hard drive(C drive).
 I noticed that there are bunch of old files C:\Program Files\Microsoft\Exchange Server\V14\Logging\lodctr_backups folder dated from 2011 thru 2013 and they are taking up over 3GB of space on C drive.
 Do I need to keep any of these files?
 I set up this server around 2011 and I probably updated Exchange server once or twice in year 2003.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Vick Vega
Vick Vega
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
As I always says, before do anything create a full backup. Some times small little things can make our whole work a misery.
Once you have done the backup, delete the logs. Just leave the current dated ones.

Those logs are transaction logs it wouldn't impact the server.
Also, as @Ronin stated, you can download the script from Microsoft to delete them logs and simplify your administration.
Avatar of sglee
sglee

ASKER

@Hamil,

I run Windows Server backup daily where I can go back so many months, but I will make copies of these files into another computer for a year or so.
"Those logs are transaction logs it wouldn't impact the server. " --> If this is case, do I even need to archive them?

@Ronin
I will run script and report back.
If you have the latest backup, then go ahead. It's a just in case something happen you know, you know how IT environment is.
You dont have to. But if it something happen one day and you want to see what happened you might need it.

But it's up to you.!
Avatar of sglee

ASKER

@Ronin,

I opened WindowsPowerShell,  ran this powershell command and got an "Permission related" error message:

Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\admin> get-childitem -Path C:\inetpub\logs\LogFiles\w3svc1 -recurse | where-object {$_.lastwritetime -lt
(get-date).addDays(-365)} | Foreach-Object { del $_.FullName }
Remove-Item : Cannot remove item C:\inetpub\logs\LogFiles\w3svc1\u_ex130118.log: Not Enough permission to perform opera
tion.
At line:1 char:147
+ get-childitem -Path C:\inetpub\logs\LogFiles\w3svc1 -recurse | where-object {$_.lastwritetime -lt (get-date).addDays(
-365)} | Foreach-Object { del <<<<  $_.FullName }
    + CategoryInfo          : PermissionDenied: (C:\inetpub\logs...\u_ex130118.log:FileInfo) [Remove-Item], IOExceptio
   n
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
First you need to allow execution of scripts on the system.
To view current permission level, execute:
Get-ExecutionPoliocy

Open in new window

Note the output.
Next, run regular PS as Administrator and set the execution policy to Unrestricted.
Set-ExecutionPolicy Unrestricted 

Open in new window

Navigate to the location of the script and execute it.
After script is finished running, set the PS execution level back to the previously recorded setting.
Avatar of sglee

ASKER

I opened Administrator:Windows PowerShell and ran Get-ExecutionPolicy and I get an error.
I ran "Set-ExecutionPolicy Unrestricted" on the same window,  successfully.
I placed ClearLogsExchange2010.PS1 file in downloads folder. In the same PowerShell window, I changed the directory to Downloads folder and ran .\ClearLogsExchange2010.PS1 and I got an error.

Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\admin> Get-ExecutionPoliocy
The term 'Get-ExecutionPoliocy' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

PS C:\Users\admin> Set-ExecutionPolicy Unrestricted

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution
policy?
[Y] Yes

PS C:\Users\admin\downloads> .\clearlogsexchange2010.ps1
Remove-Item : Cannot remove item C:\inetpub\logs\LogFiles\w3svc1\u_ex130118.log: Not Enough permission to perform operation.
It should read: Get-ExecutionPolicy and not Get-ExecutionPiolicy

Right-click on regular PS icon, not EMS, Run as Administrator
Set-ExecutionPolicy Unrestricted

Open in new window

Navigate to the location of the script, c:\temp as an example in the same PS window.
Run the script.
Wouldn't be better if you go to the directory and delete them?
Is the same thing.
Avatar of sglee

ASKER

I am still getting an same error message about permission. I right-clicked and selected "Run as Administrator".

Windows PowerShell
Copyright (C) 2009 Microsoft Corporation. All rights reserved.

PS C:\Users\admin> Get-ExecutionPolicy
Unrestricted

PS C:\Users\admin\downloads> .\clearlogsexchange2010.ps1

PS C:\Users\admin\downloads> set-executionpolicy unrestricted

Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the execution policy might expose
you to the security risks described in the about_Execution_Policies help topic. Do you want to change the execution
policy?
[Y] Yes  : Y

PS C:\Users\admin> cd downloads
PS C:\Users\admin\downloads> .\clearlogsexchange2010.ps1
Remove-Item : Cannot remove item C:\inetpub\logs\LogFiles\w3svc1\u_ex130118.log: Not Enough permission to perform opera
tion.
At C:\Users\admin\downloads\ClearLogsExchange2010.PS1:1 char:147
+ get-childitem -Path C:\inetpub\logs\LogFiles\w3svc1 -recurse | where-object {$_.lastwritetime -lt (get-date).addDays(
-365)} | Foreach-Object { del <<<<  $_.FullName }
    + CategoryInfo          : PermissionDenied: (C:\inetpub\logs...\u_ex130118.log:FileInfo) [Remove-Item], IOExceptio
   n
    + FullyQualifiedErrorId : RemoveFileSystemItemUnAuthorizedAccess,Microsoft.PowerShell.Commands.RemoveItemCommand
Go to the directory physically, if you can't delete then do the follows:

1- Right click to the folder properties.
2- Security tab
3- add user full permission, either your local user or administrator.

If it does work then go to advance and change the ownership, see my example below.
User generated image
Avatar of sglee

ASKER

@Hemil
 
 I went to C:\Program Files\Microsoft\Exchange Server\V14\Logging\lodctr_backups folder and selected all files (dated from 2011 thru 2013) and deleted them. Now the folder is empty.
 
 I wonder why there were not more recent log files in that folder?
I have no idea why you didn't see any current.
I mean you should have current logs.

But it doesn't matter through the time will generate more logs automatically. For now you have release space from your HDD.
Avatar of sglee

ASKER

"I have no idea why you didn't see any current. I mean you should have current logs. " --> C:\Program Files\Microsoft\Exchange Server\V14\Logging\lodctr_backups folder seems to contain *.bak files (some type of installation related???). They are not Exchange Transaction log files, if that is what you are trying to say.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Seth Simmons
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- Ronin (https:#a42381979)
-- Hemil Aquino (https:#a42382327)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

seth2740
Experts-Exchange Cleanup Volunteer