mardi 6 juin 2017

How to have powershell use a else statement to search another folder

I am trying to import some PST files into Outlook automatically, I currently am using the following script

Add-type -assembly "Microsoft.Office.Interop.Outlook" | out-null 
$outlook = new-object -comobject outlook.application 
$namespace = $outlook.GetNameSpace("MAPI") 
dir “$env:USERPROFILE\appdata\local\microsoft\outlook\.pst” | % { 
$namespace.AddStore($_.FullName) }

I would like to add a else statement so that if the pst file is not found in the first location then it will check in "$env:USERPROFILE\Documents\Outlook Files"

Aucun commentaire:

Enregistrer un commentaire