Greetings all,
I found this code online, and modified a little with my elementary coding skills. Basically I am hoping to achieve is that every friday dump the pst from a user to a network share. I am hoping someone could aid me in finishing this code .
Here are the parts I need.
1) Need to find ip of machine and compare it to 10.0.1.x. If that ip is within subnet, then I can run code as long as it is also friday today.
2) Copy pst to a network share.
My goal is to put script in Group Policy under logoff script, but I only want the main part of the code to run if it is friday, and the user is in a particular subnet( we have mobile users).
Thanks all
I found this code online, and modified a little with my elementary coding skills. Basically I am hoping to achieve is that every friday dump the pst from a user to a network share. I am hoping someone could aid me in finishing this code .
Here are the parts I need.
1) Need to find ip of machine and compare it to 10.0.1.x. If that ip is within subnet, then I can run code as long as it is also friday today.
2) Copy pst to a network share.
My goal is to put script in Group Policy under logoff script, but I only want the main part of the code to run if it is friday, and the user is in a particular subnet( we have mobile users).
Thanks all
Code:
Set oOutlook = CreateObject("Outlook.Application")
Set oNS = oOutlook.GetNamespace("MAPI")
'only run this entire code if today is friday and the ip of this
'computer is in subnet 10.0.1.x
'todo1: if today is friday and with are in subnet 10.0.1.x run
'rest of code
dim paths(3)
path = ""
x = 0
For Each oFolder In oNS.Folders
path = GetPSTPath(Replace(oFolder.StoreID, "00", ""))
if path <> "" then
paths(x) = path
WScript.Echo paths(x), "(" & oFolder.Name & ")"
x = x+1
end if
Next
Set oNS = Nothing
Set oOutlook = Nothing
Set oWMIService = GetObject("winmgmts:\\.\root\cimv2")
Set cServices = oWMIService.ExecQuery _
("Select * From Win32_Process where Name = 'Outlook.exe'")
For Each oApp In cServices
oApp.Terminate
Next
'have paths in array copy to network shares.
'have x number of paths.
'todo2: pull path from array and copy to network share
'Translate a hex string to character and extract the path
Function GetPSTPath(input)
sPath = ""
For i = 1 To Len(input) Step 2
sPath = sPath & ChrW("&H" & Mid(input,i,2))
Next
p = InStr(sPath, ":\")
q = InStr(sPath, "\\")
If p > 0 Then GetPSTPath = Mid(sPath,p-1)
If q > 0 Then GetPSTPath = Mid(sPath,q-1)
End Function