Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

Help with creating an EVPM script to ingest PST's - difficulty - scripting the filename autmatically

Created: 22 Oct 2010 • Updated: 21 Dec 2012 | 6 comments
This issue has been solved. See solution.

Good evening all! I'm hoping someone with better vbscript skills than myself, or someone who has already done this can help me out.

I'm looking to ingest upwards of 30K to 40K PST files into a shared archive. So, I know the EVPM scripting and .ini files will work for this, but the problem is you can't specify a [PST] File descripter with a wildcard. So, I've got  directory with say 1K of PST's. I need to generate an EVPM script INI utilizing all these file names. Anyone have a ready made solution, or could help me with the scripting?

Thanks much in advance,

Mike S

Comments 6 CommentsJump to latest comment

JesusWept3's picture

This isn't an ideal solution, but here's what i just knocked up quickly, may work as a good starting point

  1. Created the following folder structure
    - C:\Test
    - C:\Test\EVPM
    - C:\Test\PSTs
     
  2. Created a template INI File called C:\Test\TemplateEVPM.ini
  3. Edited the template to have FileName = <&&FILENAME&&>
  4. Created a VBScript to list out all the PST files located in C:\Test\PSTs
  5. It then copies the TemplateEVPM.ini to C:\Test\EVPM\[pstfileName].ini
  6. After the copy it then replaces <&&FILENAME&&> with the PSTFile name and location
  7. Then it runs EVPM.exe after each INI is created

C:\Test\TemplateEVPM.ini

	[Directory]
	DirectoryComputerName = evserver1
	sitename = EVSite

	[PSTDefaults]
	MigrationMode=process
	PSTLanguage=Western European
	ConcurrentMigrations=1
	IncludeDeletedItems=True
	ShortcutMode=NoShortcuts

         [PST] 
         FileName=<&&FILENAME&&> 
         ArchiveName=myArchive
         RetentionCategory=General
         ServerComputerName=evserver1.myDomain.com

C:\Test\GenerateEVPMs.vbs

On Error Resume Next


' Dim the file system objects
Dim EVPMObj, ReadEVPM, WriteEVPM, PSTFile, fso
Dim EVPMFileName, PSTFileName, EVPMContents, folder, files, sFolder    
	
Set fso = CreateObject("Scripting.FileSystemObject")
Set folder = fso.GetFolder("C:\Test\PSTs")
Set files = folder.Files
		
For each folderIdx In files
	WScript.Echo "Found The following PST File " & folderIdx.Name
	Set TemplateEVPM = fso.GetFile("c:\test\TemplateEVPM.ini")
	EVPMFileName = "C:\Test\EVPM\" & folderIdx.Name & ".ini"
	PSTFileName = "C:\Test\PSTs\" & folderIdx.Name
	TemplateEVPM.Copy(EVPMFileName)


	Set EVPMObj = CreateObject("Scripting.FileSystemObject")
	Set ReadEVPM = EVPMObj.OpenTextFile(EVPMFileName, 1)  
	EVPMContents = ReadEVPM.ReadAll 
	ReadEVPM.Close
	
	PSTFile = Replace(EVPMContents, "<&&FILENAME&&>", PSTFileName) 
	Set WriteEVPM = EVPMObj.OpenTextFile(EVPMFileName, 2) 
	WriteEVPM.WriteLine PSTFile 
	WriteEVPM.Close

	EVPMCommand = """C:\Program Files\Enterprise Vault\EVPM.exe"" -e exchServer.myDomain.com -m EVSysMailbox -f " & EVPMFileName
	WScript.Echo "Starting Import of " & PSTFileName
	
	Set wshShell = WScript.CreateObject ("WSCript.shell")
	wshshell.run EVPMCommand, 6, True
	set wshshell = nothing
Next

To Run the file open a command prompt and type "cscript generateEVPMs.vbs" The output should look like this

	C:\Test>cscript GenerateEVPMs.vbs
	Microsoft (R) Windows Script Host Version 5.8
	Copyright (C) Microsoft Corporation. All rights reserved.
         Found The following PST File application.pst
         Found The following PST File eventgateway.pst
         Found The following PST File exception.pst
         Found The following PST File server.pst

Although this works quite well for 10-15 PST files, I don't know how well it will work with 40,000 of them.
Also i'm not quite sure if you want to be importing them all in to an entire archive

Some things to do for this script is to possibly either delete or rename each .ini file after the imports complete
Also have it filter on just PST Files as opposed to all files in a certain directory (which this one does)
If you wanted it to be a bit more efficient you could change it so it puts 5 PST files per INI file and up the concurrent imports

mstawchansky's picture

Thanks much. I'll give this a run today and let you know how it works. Very much appreciated!

JesusWept3's picture

If i were you for the testing, copy out 100 PST files (make a copy, don't move them)

The reason i say copy and test is because EV Will delete the contents of items its ingested, so if you were to do it to a test archive straight off and you werent happy with the results, well now you've lost the contents of the PST file to start again.

You may also want to put something in the code that renames each INI file after its completed or to delete it, oh and pay attention to On Error Resume Next that means that if it encounters any errors it will just soldier on and you may think nothings wrong but it's silently throwing errors that it won't display
 

TimHudson's picture

When I try to run this, the .ini files don't populate with anything.  So I commented out "on error resume next" to see what was happening.  I get an error on line 27 Invalid Procedure Call or Argument 800A0005.  Googling this in relation "WriteLine" I found some references this being caused by trying to copy text from a unicode file.  I tried saving the vbs file as unicode, but that didn't seem to help.  Any idea what I need to do with that?

JesusWept3's picture

i'll check in to it for you, i do believe though with this script there would be an issue regarding unicode, since all EVPM scripts need to be pushed out to unicode and not ANSI

my first guess though is that its these two lines

- Set TemplateEVPM = fso.GetFile("c:\test\TemplateEVPM.ini")
- EVPMFileName = "C:\Test\EVPM\" & folderIdx.Name & ".ini"
 

Either it can't read the TemplateEVPM.ini (is it the correct location) or the EVPMFileName part for where the EVPMs go is wrong. just needs more bullet proofing and correction, will look at it in a bit

SOLUTION