AoN
Internet Programmer
- Aug 1, 2012
- 114
That makes me sad...I can't edit my post anymore, forcing me to double-post.
Oh well, I actually have another snag. ^^'
The below code is for backing up the PST mappings.
I've set it up stand-alone, with all the information provided. Now, the script runs just fine as it is, meaning it does what it is programmed to do (create a .vbs on the remote machine and then execute it), the issue is with the credentials it is executed under. The generated script works perfectly fine when ran manually, meaning the user navigates to the designated directory where it is created and runs it. Through this script, it runs, but with the remote users credentials (administrative rights). Our admin accounts don't have e-mail, and even if they did (I tested with a dummy network where users have higher permissions) it would pull the mapped PSTs for the remote user on that machine (if I had three PSTs mapped for my e-mail on the remote machine it would list my mapped PSTs, not the target user).
That was a mouthful, without the mouth.
So, that's the basic situation. I don't figure out how to tell it to run the script with the regular users credentials without have their password (which we don't use passwords, we use Smart Cards, *sigh*). Any ideas?
Oh well, I actually have another snag. ^^'
The below code is for backing up the PST mappings.
Code:
Dim currentUser
Dim strComputer
Dim batchStoreToPath
Dim fileSys
Dim exportVBS
Dim batchStorePath
currentUser = "chris.esbrandt"
strComputer = "testmachine442962"
batchStoreToPath = "\\" & strComputer & "\d$\Documents and Settings\" & currentUser
Set fileSys = CreateObject("Scripting.FileSystemObject")
Set batchStorePath = fileSys.GetFolder(batchStoreToPath)
Set exportVBS = batchStorePath.CreateTextFile("pst.vbs", True)
exportVBS.WriteLine("Const ForWriting = 2")
exportVBS.WriteLine("Const ForAppending = 8")
exportVBS.WriteLine("")
exportVBS.WriteLine("Set objFSO = CreateObject(" & Chr(34) & "Scripting.FileSystemObject" & Chr(34) & ")")
exportVBS.WriteLine("set objNetwork = createobject(" & Chr(34) & "Wscript.Network" & Chr(34) & ")")
exportVBS.WriteLine("")
exportVBS.WriteLine("strFileName = " & Chr(34) & ".\PST-Log.log" & Chr(34) & "")
exportVBS.WriteLine("")
exportVBS.WriteLine("If objFSO.FileExists(strFileName) Then")
exportVBS.WriteLine(" Set objFile = objFSO.OpenTextFile(strFileName, ForAppending)")
exportVBS.WriteLine(" CheckPST")
exportVBS.WriteLine("Else")
exportVBS.WriteLine(" Set objFile = objFSO.CreateTextFile(strFileName, ForWriting)")
exportVBS.WriteLine(" CheckPST")
exportVBS.WriteLine("End If")
exportVBS.WriteLine("objFile.Close")
exportVBS.WriteLine("")
exportVBS.WriteLine("Sub CheckPST")
exportVBS.WriteLine(" Set objOutlook = CreateObject(" & Chr(34) & "Outlook.Application" & Chr(34) & ")")
exportVBS.WriteLine(" Set objMAPI = objOutlook.GetNamespace(" & Chr(34) & "MAPI" & Chr(34) & ")")
exportVBS.WriteLine(" For Each PSTFolder In objMAPI.Folders")
exportVBS.WriteLine(" objFile.Writeline GetPath(PSTFolder.StoreID)")
exportVBS.WriteLine(" Next")
exportVBS.WriteLine("End Sub")
exportVBS.WriteLine("")
exportVBS.WriteLine("Function GetPath(input)")
exportVBS.WriteLine(" For i = 1 To Len(input) Step 2")
exportVBS.WriteLine(" strSubString = Mid(input,i,2)")
exportVBS.WriteLine(" If Not strSubString = " & Chr(34) & "00" & Chr(34) & " Then")
exportVBS.WriteLine(" strPath = strPath & ChrW(" & Chr(34) & "&H" & Chr(34) & " & strSubString)")
exportVBS.WriteLine(" End If")
exportVBS.WriteLine(" Next")
exportVBS.WriteLine("")
exportVBS.WriteLine(" Select Case True")
exportVBS.WriteLine(" Case InStr(strPath," & Chr(34) & ":\" & Chr(34) & ") > 0")
exportVBS.WriteLine(" GetPath = Mid(strPath,InStr(strPath," & Chr(34) & ":\" & Chr(34) & ")-1)")
exportVBS.WriteLine(" Case InStr(strPath," & Chr(34) & "\\" & Chr(34) & ") > 0")
exportVBS.WriteLine(" GetPath = Mid(strPath,InStr(strPath," & Chr(34) & "\\" & Chr(34) & "))")
exportVBS.WriteLine(" End Select")
exportVBS.WriteLine("End Function")
exportVBS.Close
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2:Win32_Process")
objWMIService.Create batchStoreToPath & "pst.vbs", Null, Null, intProcessID
WScript.Quit
I've set it up stand-alone, with all the information provided. Now, the script runs just fine as it is, meaning it does what it is programmed to do (create a .vbs on the remote machine and then execute it), the issue is with the credentials it is executed under. The generated script works perfectly fine when ran manually, meaning the user navigates to the designated directory where it is created and runs it. Through this script, it runs, but with the remote users credentials (administrative rights). Our admin accounts don't have e-mail, and even if they did (I tested with a dummy network where users have higher permissions) it would pull the mapped PSTs for the remote user on that machine (if I had three PSTs mapped for my e-mail on the remote machine it would list my mapped PSTs, not the target user).
That was a mouthful, without the mouth.
So, that's the basic situation. I don't figure out how to tell it to run the script with the regular users credentials without have their password (which we don't use passwords, we use Smart Cards, *sigh*). Any ideas?