VBS Script for System Administrators - How to backup Outlook email automatically in a login or logoff script Script VBS pour les administrateurs de système - Comment sauvegarde messagerie Outlook automatiquement dans un script de connexion ou de déconnexion

Posted on March 13, 2007 at 8:11 am Posté le 13 mars 2007 à 8h11

If you are a Systems Administrator for your company and everyone is using Outlook or some other desktop email program, you’ve probably run into the situation where someone has lost all of their emails due to the fact that it’s saved locally on the user’s computer and not on the main servers. Si vous êtes un administrateur de systèmes pour votre entreprise et tout le monde utilise Outlook ou d'un autre programme de messagerie de bureau, vous avez probablement courir dans la situation où une personne a perdu la totalité de leurs e-mails en raison du fait qu'il est sauvegardé localement sur l'utilisateur L 'ordinateur et non sur les principaux serveurs. So if you’re a small shop and can’t afford to get Exchange server, then here’s a simply way to automate the backup of user’s Outlook PST files onto your server in a login or logoff script. Ainsi, si vous êtes un petit magasin, et ne peuvent pas se permettre d'obtenir serveur Exchange, alors voici un moyen simple d'automatiser la sauvegarde de l'utilisateur Outlook PST fichiers sur votre serveur dans un script de connexion ou de déconnexion.

First here’s the code and then I’ll explain it: Premièrement, voici le code, puis je vais l'expliquer:

Set shell= WScript.CreateObject(”WScript.Shell”) Set coque = WScript.CreateObject ( "WScript.Shell")
strUserName = shell.ExpandEnvironmentStrings(”%USERNAME%”) StrUserName = shell.ExpandEnvironmentStrings ( "% USERNAME%")

Dim fso Dim FSO
set fso = CreateObject(”Scripting.FileSystemObject”) Ensemble fso = CreateObject ( "Scripting.FileSystemObject")

lnDayOfWeek = weekday(now()) LnDayOfWeek = jours de la semaine (maintenant ())

if lnDayOfWeek = 5 then Si lnDayOfWeek = 5 alors

     If fso.DriveExists(”G:”) Then Si fso.DriveExists ( "G") Then

          Dim lcDrive Dim lcDrive
          Set lcDrive = fso.GetDrive(”G:”) Set lcDrive = fso.GetDrive ( "G")

          If lcDrive.IsReady Then Si lcDrive.IsReady Puis

               newfolderpath = “\\servername\users\” & strUserName & “\EmailBackup” Newfolderpath = "\ \ serveur \ utilisateurs \" & strUserName & "\ EmailBackup"

               If Not fso.FolderExists(newfolderpath) Then If Not fso.FolderExists (newfolderpath) Then
                    Set newfolder = fso.CreateFolder(newfolderpath) Set newfolder = fso.CreateFolder (newfolderpath)
               End If Fin Si

                Dim file Dim fichier
               file = “C:\Documents and Settings\” & strUserName & “\Local Settings\Application Data\Microsoft\Outlook\Outlook.pst” Fichier = "C: \ Documents et Settings \" & strUserName & "\ Local Settings \ Application Data \ Microsoft \ Outlook \ Outlook.pst"

               If fso.FileExists(file) Then Si fso.FileExists (fichier) Then
                    fso.CopyFile “C:\Documents and Settings\” & strUserName & “\Local Settings\Application Data\Microsoft\Outlook\Outlook.pst”, “\\servername\users\” & strUserName & “\EmailBackup\Outlook.pst” Fso.CopyFile "C: \ Documents et Settings \" & strUserName & "\ Local Settings \ Application Data \ Microsoft \ Outlook \ Outlook.pst", "\ \ serveur \ utilisateurs \" & strUserName & "\ EmailBackup \ Outlook.pst "

                    set fso = nothing Ensemble FSO = rien
                    wscript.echo “Your email has been backed up!” Wscript.echo "Votre message a été sauvegardé!"
               end if Fin si
          end if Fin si
     end If Si fin
end if Fin si

Unforunately, the code is not indented very well here, so you’ll have to copy it and fix it so that you can read it correctly. Unforunately, le code n'est pas indenté très bien ici, vous devrez donc le copier et de le corriger pour que vous puissiez lire correctement. Basically, it starts off creating a FileSystem object that will take care of copying the file to the server. Fondamentalement, cela commence FileSystem création d'un objet qui se charge de copier le fichier sur le serveur. Then I do a check to see which day of the week it is and I use 5 (Friday), so that the script only runs once a week. Puis je fais une vérification pour voir quel jour de la semaine et il est j'utilise 5 (vendredi), de sorte que le script fonctionne uniquement une fois par semaine. I also do a check to make sure the G drive is available (the network drive I’m going to be copying the data to) before I get to the copying. Je voudrais également faire une vérification pour s'assurer que le lecteur G est disponible (le lecteur réseau, je vais être la copie de) avant de me rendre à la copie.

Then I check to see if the folder exists that I want to copy to and if not, I go ahead and create that folder in the user’s folder on the server. Ensuite, je vérifie si le dossier existe, que je veux copier et sinon, je aller de l'avant et de créer un dossier dans le dossier utilisateur sur le serveur. I also check to make sure the file exists and if so, I then copy it to the user’s folder on the network. J'ai également vérifier si le fichier existe et si c'est le cas, je puis le copier dans le dossier de l'utilisateur sur le réseau. I use the shell.ExpandEnvironmentStrings(”%USERNAME%”) method to get the current user’s username. J'utilise le shell.ExpandEnvironmentStrings ( "% USERNAME%") pour obtenir l'utilisateur actuel.

You can then apply this as either a logon or logoff script using Group Policy! Vous pouvez ensuite appliquer ce soit comme un script de connexion ou de déconnexion en utilisant une stratégie de groupe!

Related Posts: Postes connexes:

More VBS Scripts for System Administrators Plus de scripts VBS pour les administrateurs système

Office Ergonomics - Risks of working at a desktop workstation and how to avoid them Office Ergonomics - Risques de travailler dans un bureau de poste de travail et comment les éviter

Gliffy - Online tool to create and share diagrams for free Gliffy - outil en ligne pour créer et partager des diagrammes gratuitement

Great tool for Help Desk/System Admintrator Professionals - Change Analysis Diagnostic tool Bon outil pour le Help Desk / Système Admintrator Professionals - Change Analysis outil de diagnostic

If you enjoyed this post, make sure you Si vous avez apprécié ce poste, assurez-vous que vous subscribe to my RSS feed Souscrire à mon flux RSS ! !

» Filed Under »Filed Under IT Job Stuff Elle Job Stuff

Related Posts Postes connexes

One Response to “VBS Script for System Administrators - How to backup Outlook email automatically in a login or logoff script” Une réponse à "Script VBS pour les administrateurs de système - Comment sauvegarde messagerie Outlook automatiquement dans un script de connexion ou de déconnexion"

  1. Jemas said on : Jemas dit sur:

    Like your script, for home user how can I modify it to do a backup to external hard drive on a daily basis. À l'instar de votre script, pour la maison utilisateur comment puis-je la modifier pour en faire une sauvegarde de disque dur externe sur une base quotidienne. Thanks Merci


    Please post your comments/suggestions! Envoyez vos commentaires et suggestions!