Google
Showing posts with label Exchange. Show all posts
Showing posts with label Exchange. Show all posts

Thursday, January 3, 2008

VBScript: Search Files Older than 30 Days (including sub folder) and Move to Another Location

Sometime we need an automated task to move some of the files from one location to another, examples are bleow.
· SMTP Logs
· SPAM Product Logs
· Some Application Logs
· Temporary Files

So I have created a script that allows you to search all files in a location (including sub folders) which are older than 30 days, move it to specified location and record it into a log file “Move-Result.txt”.

Give the input path where you want to search the files at below line in the script.
SPath = "c:\temp\"

Give the path of destination location at below line in the script.
objFSO.MoveFile FileName, "d:\test\"


====== Script Code ======
Dim objFSO, ofolder, objStream

Set objShell = CreateObject("WScript.Shell")
Set objFSO = CreateObject("scripting.filesystemobject")
Set objNet = CreateObject("WScript.NetWork")
Set FSO = CreateObject("Scripting.FileSystemObject")
set outfile = fso.createtextfile("Move-Result.txt",true)
SPath = "c:\temp\"

ShowSubfolders FSO.GetFolder(spath)

Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
CheckFolder(subfolder)
ShowSubFolders Subfolder
Next
End Sub

'CheckFolder(objFSO.getFolder(SPath))

Sub CheckFolder(objCurrentFolder)
Dim strTempL, strTempR, strSearchL, strSearchR, objNewFolder, objFile
Const OverwriteExisting = TRUE
currDate = Date
dtmDate = Date - 30
strTargetDate = ConvDate(dtmDate)
For Each objFile In objCurrentFolder.Files
FileName = objFile
'WScript.Echo FileName
strDate = ConvDate(objFile.DateCreated)
'strDate = ConvDate(objFile.DateLastModified)
If strDate < strTargetDate Then
objFSO.MoveFile FileName, "d:\test\"
outfile.writeline filename
End If
Next
End Sub

Function ConvDate (sDate) 'Converts MM/DD/YYYY HH:MM:SS to string YYYYMMDD
strModifyDay = day(sDate)
If len(strModifyDay) < 2 Then
strModifyDay = "0" & strModifyDay
End If
strModifyMonth = Month(sDate)
If len(strModifyMonth) < 2 Then
strModifyMonth = "0" & strModifyMonth
End If
strModifyYear = Year(sDate)
ConvDate = strModifyYear & strModifyMonth & strModifyDay
End Function
====== Script Code ======

Thursday, December 27, 2007

Mailbox is empty - but ESM still shows size & count…

In last couple of months I have encountered couple of problem with same symptoms and heard a lot problem in newsgroups also.


Let’s consider the symptoms first:

• In the Exchange System Manager you have a Mailbox that says that it has 33 items and is a total size of 42,008 KB




• User has cleared down all their e-mail in the Inbox, Sent Items, Deleted items so they have a almost empty mailbox, but the Exchange System manager still claims that the mailbox contains items and those items amount to several Megabytes in size.




Some of the guys assume that mailbox is corrupted so delete it and re-create the exchange attributes with fresh mailbox to solve this issue, but we can go through below solution.


Solution Steps:

• Try to move mailbox from one Mailbox Store to another and check if you can see the location of any hidden item. Location might be Root, Inbox, Calendar etc…





• From the Microsoft Exchange web-site you will need to download the “Microsoft Exchange Server MAPI Editor” – to a machine where Outlook installed.



Note: Before we begin I have to tell you the fact that MAPI Editor is a pretty dangerous tool, it should be used with care and any small misuse could result in the loss of data or a mailbox being completely unreadable – take care and as always ensure that you have a working backup.



Configure outlook profile with the affected user’s mailbox.

Double click on the MFCMAPI.exe file and you will be having following screen:




Click on the OK button then go to the “SESSION” menu and select “Logon and Display Store Table”;



This will bring a pop-up for MAPI profile selection box (only if you have multiple MAPI profiles configured in machine);


Choose the correct profile from the list – or if you do not get the profile selection tab then proceed to the next stage

The MAPI Editor screen will change to look like the following;


You will need to double click on the item entitled “Mailbox – <<>>" and a new Window will open which looks like the following (you will have to expand the item called the “Root Container”):


Double click on the option in the left hand tree entitled “Top of Information Store” – following Window will be opened:

As you can see, in the top plane you can see all of the items that appear to be missing:

You can select all the messages above and export them to EML files, go to the “ACTIONS” menu and choosing the “SAVE TO FILE


Then you can go to the “Actions” menu and choose the “DELETE MESSAGES” option – this will prompt you with the following question:


Choose the “Permanent delete passing DELETE_HARD_DELETE (unrecoverable)” option – this will ensure that the items have been fully removed from the Information Store.


When you have deleted all hidden mails, close down the MAPI editor.

Final View in ESM:

Refresh the view and you will have below view in ESM


Mystery solved!

Monday, April 16, 2007

Recover Shift Deleted Mails through OWA

If you have deleted some mails with shift delete key, you can't recover through Recover Deleted Items in outlook.

OWA can also help in this case . . . open OWA with below link & enjoy recovering. . .

http://(Exchange Server Name)/Exchange/(User Logon ID)/(folder name)/?cmd=showdeleted
Google Groups
Subscribe to IT_Discussions
Email:
Visit this group