Skip to main content

Modifying Outlook profiles in Outlook 2010 with VBS and Powershell

Outlook profiles can present somewhat of a challenge to any mail administrator regardless of the size of the mail system. One way of looking at Outlook profiles is that they are just a whole collection of registry settings on a machine which is true but the number and compelxity of structures involved means that if you want to write a script that will modify a particular profile for a particular user its not just as simple as modifying a single registry key. In previous versions of Outlook you could generally rely on the GUID "13dbb0c8aa05101a9bb000aa002fc45a" to locate the key where the values for the Exchange settings are located but if you have done any work with Outlook 2010 on windows 7 you will generally find this is nolonger the case and its now more reliable to enumerate all the keys under a particular profile and find a particular setting which will indicate this particular key has the values for the Exchange Setting you want to modify. The one thing that computers are really good at is processing things quickly so if you wanted to for instance modify the cache mode setting within a profile in VBS you could use the following code to locate the default profile

Set WshShell = WScript.CreateObject("WScript.Shell")
strComputer = "."
Set oReg = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
keypath = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\"

profile = WshShell.RegRead("HKCU\"&keypath&"DefaultProfile")

Then enumerate all the keys under this profile to identify the key that has the cache mode value.

oReg.EnumKey HKEY_CURRENT_USER, (keypath & profile & "\"), arrSubKeys
For Each subkey In arrSubKeys
oReg.EnumValues HKEY_CURRENT_USER, (keypath & profile & "\" & subkey & "\"), arrSubValues
on error resume next
for each ValueKey in arrSubValues
if ValueKey = "00036601" then
oReg.GetBinaryValue HKEY_CURRENT_USER,(keypath & profile & "\" & subkey),"00036601",prProxyValRes
if not IsNull(prProxyValRes) then
if prProxyValRes(0) = "132" then
Wscript.echo "Cache Mode Enabled"
Wscript.echo "Cache Mode Disabled"
end if
end if
end if
on error goto 0

If you want to change the setting instead of just echoing it out the current setting then you would need to include something like

newValue1 = Array(&H84,&H05,&H00,&H00)
oReg.SetBinaryValue HKEY_CURRENT_USER,(keypath & profile & "\" & subkey),"00036601",newValue1

Note the hex value that you put in the second array element can vary depending on whether you want to enable the download public folder or shared folders check boxes.

If you think vbs is for mugs and you want to do this in powershell instead then you would need something like this

$RootKey = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles"
$pkProfileskey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey($RootKey, $true)
$defProf = $pkProfileskey.GetValue("DefaultProfile")
$pkSubProfilekey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey(($RootKey + "\\" + $defProf), $true)
foreach($Valuekey in $pkSubProfilekey.getSubKeyNames()){
$pkSubValueKey = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey(($RootKey + "\\" + $defProf + "\\" + $Valuekey ), $true)
foreach ($values in $pkSubValueKey.GetValueNames())
if ($values -eq "00036601"){
if(($pkSubValueKey.GetValue("00036601"))[0] -eq 132){
"Cache Mode Enabled"}
"Cache Mode Disabled"


Popular posts from this blog

Export calendar Items to a CSV file using EWS and Powershell

Somebody asked about this last week and while I have a lot of EWS scripts that do access the Calendar I didn't have a simple example that just exported a list of the Calendar events with relevant information to a CSV file so here it is. I've talked on this one before in this howto  but when you query the calendar folder using EWS you need to use a CalendarView which will expand any recurring appointments in a calendar. There are some limits when you use a calendarview in that you can only return a maximum of 2 years of appointments at a time and paging will limit the max number of items to 1000 per call. So if you have a calendar with a very large number of appointments you need to break your query into small date time blocks. In this example script I'm just grabbing the next 7 days of appointments if you want to query a longer period you need to adjust the following lines (keeping in mind what I just mentioned) #Define Date to Query $StartDate = (Get-Date) $EndDate

Downloading a shared file from Onedrive for business using Powershell

I thought I'd quickly share this script I came up with to download a file that was shared using One Drive for Business (which is SharePoint under the covers) with Powershell. The following script takes a OneDrive for business URL which would look like This script is pretty simple it uses the SharePoint CSOM (Client side object Model) which it loads in the first line. It uses the URI object to separate the host and relative URL which the CSOM requires and also the SharePointOnlineCredentials object to handle the Office365 SharePoint online authentication. The following script is a function that take the OneDrive URL, Credentials for Office365 and path you want to download the file to and downloads the file. eg to run the script you would use something like ./spdownload.ps1 '

Writing a simple scripted process to download attachmentts in Exchange 2007/ 2010 using the EWS Managed API

Every complicated thing in life is made up of smaller simpler building blocks, when it comes to writing a script (or any code really) the more of these little building blocks you have to figure out the more the process of solving a problem can become bewildering. The Internet generally provides you with lots of half eaten sandwiches of information something someone else has taken a bite out but a lot of the time half done, and as with any code its usefulness declines over time as new and better API's and methods are derived. In this post I'm going to go through a simple scripted process that hopefully covers a few more of these smaller building blocks that you might face when asked to come up with a simple costless solution to perform an automated business function with a script. So the process im going to look at is one that comes up a lot and that is you have an Email that comes into to certain mailbox every day with a certain subject in my case "Daily Export" this
All sample scripts and source code is provided by for illustrative purposes only. All examples are untested in different environments and therefore, I cannot guarantee or imply reliability, serviceability, or function of these programs.

All code contained herein is provided to you "AS IS" without any warranties of any kind. The implied warranties of non-infringement, merchantability and fitness for a particular purpose are expressly disclaimed.