打印

[求助] Exchange2003 Program咨询,如何取得该值?

Exchange2003 Program咨询,如何取得该值?

请问有谁知道如何取得Exchange数据库的“上次完整备份时间”和“上次增量备份时间”的值,使用adsi、CDOEXM或者wmi都可以。* F2 F# b0 @8 v8 |7 F
查了一下相关手册,但是不知道有没有这个属性。
: ]5 B# L" o9 k7 }- g p
0 J& S& G1 T) V+ i5 _/ c希望有相关编程经验高手帮助:): x$ ?6 [! I: z t: B1 w
2 a( O$ q* |! U) X
[ 本帖最后由 nicktang 于 2007-7-27 13:14 编辑 ]
附件: 您所在的用户组无法下载或查看附件

TOP

just download and run this script, should works for u.
/ W4 [( s$ l2 I7 s( s4 F8 i# `, G3 A7 n7 J& B" n
more info see this link http://gsexdev.blogspot.com/2004/12/finding-when-exchange-store-last.html
, ^( b/ z3 F1 I$ M' p$ v
4 [. }3 l- h' w1 k! b B: B! ^[ 本帖最后由 mwpq 于 2007-7-27 13:49 编辑 ]
附件: 您所在的用户组无法下载或查看附件
《无量寿经·第十八愿》言:
设我得佛,十方众生,至心信乐,欲生我国,乃至十念,若不生者,不取正觉。唯除五逆,诽谤正法。

TOP

thank you!1 R& w) L# D% y
你给我的链接我google到过,但是就是打不开。说不定是被GFW限制了:)" ]& X5 \" b. m% L/ ?
/ R& B# \5 z$ J; _. A' P$ d
呵呵,原来用CDOEXM是有LastFullBackupTime这个属性的,手册里面没有找到。, i+ j( p( \6 Q# p

; h, t9 V5 {9 Z" K; `[ 本帖最后由 nicktang 于 2007-7-27 14:54 编辑 ]

TOP

Finding when a Exchange Store last backed up via script
" e* |; c* J* lThere are a couple of ways you can determine when the last time a particular exchange store was backed up if you're using a program that backs up via the Exchange Backup API (Veritas,Brightstore etc).
$ h2 j; C: `- Q: O) N8 H" @6 y' q" k# B
With Exchange 2003 a new function was added into System Manager to allow you to see the "Time of Last Full Backup" on the database tab. This property is also available in CDOEXM (if you have the 2003 version of system manager loaded on the machine). The ".LastFullBackupTime" property was added to the IMailStoreDB and IPublicStoreDB interfaces. Using this is pretty easy all you have to do is to open the mailstore using the LDAP DN path and access the property eg( z( ~& w" p, U

% t" m. Z7 V% g2 d9 n1 W) Q: Zset mdbobj = createobject("CDOEXM.MailboxStoreDB")
( a I9 `' M# r4 [0 y9 Emdbobj.datasource.open "LDAP://mbdDNpath" H, b8 N) }" r" `, H4 P' j
Wscript.echo "Last Backed Up : " & mdbobj.LastFullBackupTime9 W' Q- Y/ [$ x/ G) S! c0 \
: [+ S) ?& a- g$ n) u" O( D9 A1 e
I've put this together with a similar query from my previous post and this script selects all the exchange stores in a domain and reports when the last time they where backed up. I've posted the code here (this will on work on Exchange 2003)
$ u. j: ?1 S3 @
4 t, H1 {8 \' yAnother method you can use to do this is to query the eventlog on each of your servers and look for each of the 221 completion events for each of the database files. When the backup runs on a Exchange server you get a bunch of really useful events that tell you when the backup started, how much was backed up and when it finished. In this script im focusing on the finished events which include the path to the database file. So if I combine it with the script from my previous post which was already getting the server name and file path of each of the database files. You end up with a script that will query Active directory for every mail and public folder store then query the event log via WMI to work out when the last time a backup occurred of each file and display the result on the commandline. Note I've limited the search range to the last 7 days so if a server hasn't backed up in the last 7 days you receive a no backup recorded message. This was done to keep the time it takes to run the script to a minumn as searching through a really large event log can be very time consuming. I've posted a copy of the script here The code look like: v& H. l3 C) ~5 c
" y5 p8 F- B5 `7 e5 x" |
9 w) e8 ~$ Q' @
set conn = createobject("ADODB.Connection") K- L) s' {! j2 b& b4 n
set com = createobject("ADODB.Command")
) o4 M" a8 Z4 @3 n5 d) ZSet iAdRootDSE = GetObject("LDAP://RootDSE")
0 |' q# i# E' SstrNameingContext = iAdRootDSE.Get("configurationNamingContext")5 |8 V; G& T2 t
rangeStep = 999- x+ N8 j) i3 k1 k s9 t
lowRange = 0! Q) f' M' l1 S/ y' U. z( p
highRange = lowRange + rangeStep
' q9 R3 ~; e( {, i3 DConn.Provider = "ADsDSOObject"
$ n$ t5 D- [6 L3 sConn.Open "ADs Provider"
' d! m: ^7 b5 A; d* A F4 ]" E- l5 d5 O; ~. ^mbQuery = "pfQuery = "Com.ActiveConnection = Conn
9 ^( C0 q# a! D8 u9 e& y' xCom.CommandText = mbQuery& G3 x6 |5 [& m) k. I5 Y4 N. T) h5 b1 ~
Set Rs = Com.Execute
! k9 U8 j1 p& s) s7 jWscript.echo "Mailbox Stores"
0 s* P. u; _" o+ J% @8 EWscript.echo
* E% v9 T! y6 V, t, Q- cWhile Not Rs.EOF
: \2 G, F. a% L* g+ v) eobjmailstorename = "LDAP://" & Rs.Fields("distinguishedName")
; S( L. m1 j7 u9 k2 n G% |set objmailstore = getObject(objmailstorename)
, j1 p- D% N5 }" i0 wservername = mid(objmailstore.msExchOwningServer,4,instr(objmailstore.msExchOwningServer,",")-4)" y6 g; A4 }% R6 I. S7 Y* S" f% F
slvlastbackuped = queryeventlog(servername,objmailstore.msExchSLVFile)
4 W ?3 f2 _& o8 \5 Sedblastbackuped = queryeventlog(servername,objmailstore.msExchEDBFile)8 e5 }4 M ?! f4 R6 S8 S$ v
Wscript.echo Rs.Fields("name") & " Last Backed up EDB : " & edblastbackuped 8 a$ Q" v# l0 c( h$ E
Wscript.echo Rs.Fields("name") & " Last Backed up STM : " & slvlastbackuped2 J* n$ s ]1 Y/ O% f! g9 ]
wscript.echo 1 Z% \" I( g/ T! `% F6 ]
Rs.MoveNext) f- c; x/ V4 Z( A8 C( M
% q* a1 W" O5 _9 ?* p) C
Wend
1 y" Z) m* k( o) E' SWscript.echo "Public Folder Stores"4 i- `5 v8 V% w! w+ v: E
Wscript.echo- ^9 B, Q" X, |8 E! Q4 ~
Com.CommandText = pfQuery# b7 s! c' O; X( V
Set Rs1 = Com.Execute5 k2 O! y# S0 W. x7 A
While Not Rs1.EOF' i! u8 Z: {' a5 e
objmailstorename = "LDAP://" & Rs1.Fields("distinguishedName")
9 Z5 |- \7 @9 _- q( }, a) x; uset objmailstore = getObject(objmailstorename)
* L3 F+ L w: f0 M' r4 ^, _* |servername = mid(objmailstore.msExchOwningServer,4,instr(objmailstore.msExchOwningServer,",")-4)( I2 k; `# X% K0 `/ w. \; l
slvlastbackuped = queryeventlog(servername,objmailstore.msExchSLVFile)
' J- T- K& l: z+ A" ledblastbackuped = queryeventlog(servername,objmailstore.msExchEDBFile)* d! `3 n J# x2 q2 ^3 ]% H
Wscript.echo Rs1.Fields("name") & " Last Backed up EDB : " & edblastbackuped
' G9 d5 M! i, S6 ZWscript.echo Rs1.Fields("name") & " Last Backed up STM : " & slvlastbackuped
V- W( F7 G8 ^+ y9 s( Cwscript.echo
* D- I7 k) R- {7 W9 e0 g% [+ z" D$ uRs1.MoveNext
; r B \/ Y2 }- M
( y' C7 X7 _" r; q( NWend
# x; J* t, z# b* T$ \0 YRs.Close- U# j5 R! R4 U& ?
Rs1.close/ U' x3 M3 Z Q& }- b( i
Conn.Close3 f# Z3 ~8 i1 ^' _" V( m4 S6 t
Set Rs = Nothing
$ [( p7 [& D% R4 r0 d6 i- pSet Rs1 = Nothing
/ u% ^( I5 x& @" dSet Com = Nothing
% Z, y# U& K2 n" k7 E, ?3 Q; jSet Conn = Nothing
. L! q; Z: W: o/ _) J) C' s+ Z# T; q4 S! u6 M* M# C( w

; k6 q! ?7 n( T1 c. x3 }function queryeventlog(servername,filename)3 o* L+ ?! `) p v( y+ S5 |, s, Z! s
SB = 0
8 h# n8 B. r8 J" h3 bdtmStartDate = CDate(Date) - 7
/ e/ ^, S+ d- jdtmStartDate = Year(dtmStartDate) & Right( "00" & Month(dtmStartDate), 2) & Right( "00" & Day(dtmStartDate), 2), n6 Q y6 J3 O. f. r# ]
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & servername & "\root\cimv2")
% s8 Q U Y) @4 R1 n2 iSet colLoggedEvents = objWMIService.ExecQuery("Select * from Win32_NTLogEvent Where Logfile='Application' and Eventcode = '221' and TimeWritten >= '" & dtmStartDate & "' ",,48)/ V7 g B! a/ I1 A
For Each objEvent in colLoggedEvents' \7 O# C/ V0 w* f
SB = 1% P4 H3 B7 \4 G% U% O
Time_Written = objEvent.TimeWritten
4 A+ h7 k% Y8 X+ Q2 i& g: `Time_Written = left(Time_Written,(instr(Time_written,".")-1))
% C7 n$ ?5 e$ C% W) [if instr(objEvent.Message,filename) then
3 c. s7 p$ h* a8 N# W0 f3 S9 B. Xqueryeventlog = dateserial(mid(Time_Written,1,4),mid(Time_Written,5,2),mid(Time_Written,7,2)) & " " & timeserial(mid(Time_Written,9,2),mid(Time_Written,11,2),mid(Time_Written,13,2))9 j: N; ?- b0 I5 V$ T0 a* P
exit for
- W/ u6 u6 M8 mend if
[' k% w' V. v o( x* Jnext
3 c$ N/ X) M2 Y2 d) [0 Tif SB = 0 then queryeventlog = "No Backup recorded in the last 7 Days"+ r/ W( ^- E8 p. o; [; O7 [
end function
《无量寿经·第十八愿》言:
设我得佛,十方众生,至心信乐,欲生我国,乃至十念,若不生者,不取正觉。唯除五逆,诽谤正法。

TOP