Page 1 of 1 1
Topic Options
#124322 - 2004-08-03 07:36 AM Script to check Oulook PST Size
jpg35 Offline
Fresh Scripter

Registered: 2003-08-06
Posts: 27
Loc: SoCal
Is there a script can check Outlooks PST size. I'm tired of our executive having 2 gig pst and me having to repair them.

I want a script upon logon to do a check and log each size of each data file, and maybe send me an email saying there email is above the limit.

This would be godsend. Anyone have one simular to share?

Top
#124323 - 2004-08-03 10:09 AM Re: Script to check Oulook PST Size
jechilt Offline
Starting to like KiXtart

Registered: 2000-12-01
Posts: 102
Loc: Denver Colorado
I did something along these lines
Code:
 

$pstLocation = '%userprofile%\Local Settings\Application Data\Microsoft\Outlook\%username%.pst'
$pstFileSize = getFileSize($pstLocation)
$pstSize = $pstFileSize / (1024 * 1024)



we force the .pst location by way of the outlook profile generator. we chose the default microsoft location for the saving of the .pst to keep things simple. if you know where the pst file is and its name, then you are set!
we use an if statement to qualify the size we are looking for. if it is too big, we use telnet to send an email. (would use CDONTS but are not configured to access the IIS server)
If you don't know where the .pst is located, you can look for it in the registry. you should be able to locate them in HKCU\Software\Microsoft\WindowsNT\CurrentVersion\Windows Messaging Subsystem\Profiles\<<username>>
NOTE: default <<username>> is "Microsoft Outlook Settings" or something like that...

hope this helps.


Edited by jechilt (2004-08-03 12:12 PM)
_________________________
John
LM Contractor
One of the 2 dads

Top
#124324 - 2004-11-30 09:50 AM Re: Script to check Oulook PST Size
Anonymous
Unregistered


Code:
  

Function CheckPst
$Index = 0
$KeyName = EnumKey("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"+
"MS Exchange Settings", $Index)
while @error=0
$Displayname = ReadValue("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"+
"MS Exchange Settings\$Keyname", "001e6700")
If @error=0
$fso = CreateObject("Scripting.FileSystemObject")
$objFile = $fso.GetFile($Displayname)
$filesize=$objFile.Size
If $filesize>1500000000
;>1.5GB
$dev=ReadProfileString($IniFilePath,"PstID",$Displayname)
if $dev=""
WriteProfileString($IniFilePath,"PstID",$Displayname,$filesize)
$Message=$Message+"The pst file "+$Displayname+" is over size, Please notify user. The current size is : "+($filesize / 1024 /1024 ) +"MB;"
else
if $filesize-$dev>100000000
SendError("Warning!Warning!Warning!"+" The pst file "+$Displayname+
" will over maximum size , Must Be Attention!. The current size is : "+($filesize / 1024 /1024 ) +"MB;")
endif
endif
EndIf
Endif
$Index = $Index + 1
$KeyName = EnumKey("HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"+
"MS Exchange Settings", $Index)
loop
If $Message<>""
SendError($Message)
EndIf
EndFunction



Fixed long line / reformtted code

Refomatted code but not tested, original posters reformats did not reduce the long lines [NTDOC]


Edited by NTDOC (2004-11-30 07:54 PM)

Top
#124325 - 2004-11-30 02:49 PM Re: Script to check Oulook PST Size
Kdyer Offline
KiX Supporter
*****

Registered: 2001-01-03
Posts: 6241
Loc: Tigard, OR
Long line police!

Couple of things..
Like the idea of your post..

However, you don't post anything on how to use your function.. You don't define $inifilepath either.

The following should read cleaner.
Code:

FUNCTION CheckPst
$regkey='HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\MS Exchange Settings'
$index = 0
$keyname = EnumKey($regkey, $index)
WHILE @error=0
$displayname = ReadValue($regkey+'\'+$keyname,'001e6700')
IF @error=0
$fso = CreateObject('Scripting.FileSystemObject')
$objfile = $fso.getfile($displayname)
$filesize=$objfile.size
IF $filesize>1500000000 ;>1.5GB
$dev=ReadProfileString($inifilepath,'PstID',$displayname)
IF $dev=''
WriteProfileString($inifilepath,'PstID',$displayname,$filesize)
$message=$message+'The pst file '+$displayname
' is over size, Please notify user. The current size is : '
+($filesize / 1024 /1024 ) +"MB;"
ELSE
IF $filesize-$dev>100000000
SendError('Warning!Warning!Warning!'+' The pst file '+$displayname+
' will over maximum size ,
Must Be Attention!. The current size is : '
+($filesize / 1024 /1024 ) +'MB')
ENDIF
ENDIF
ENDIF
ENDIF
$index = $index + 1
$keyname = EnumKey($regkey, $index)
LOOP
IF $message<>''
SendError($message)
ENDIF
ENDFUNCTION



Thanks,

Kent
_________________________
Utilize these resources:
UDFs (Full List)
KiXtart FAQ & How to's

Top
#124326 - 2004-11-30 03:11 PM Re: Script to check Oulook PST Size
PRandal Offline
Fresh Scripter

Registered: 2002-07-17
Posts: 28
A few things of interest (having recently done this exercise):

First off, the default profile's key should be used instead of hard coding "MS Exchange Settings"

Code:

$regkey="HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"
$prof=ReadValue($regkey,"DefaultProfile")
if @ERROR = 0
$regkey=$regkey+$prof+"\"



Secondly, Outlook 2003 uses a binary value in "001f6700" (instead of "001e6700"). I used the RegHexToASCII UDF to "do the right thing" to these values.


Edited by PRandal (2004-11-30 03:15 PM)

Top
Page 1 of 1 1


Moderator:  Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 2291 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.053 seconds in which 0.023 seconds were spent on a total of 12 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org