• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Use PowerShell to Export and Import Categories

Slipstick Systems

› Outlook › Use PowerShell to Export and Import Categories

Last reviewed on June 4, 2020     8 Comments

Applies to: Outlook (classic), Outlook 365 (Win)

There are several ways you can move categories between mailboxes. The easiest, via an appointment form, does not maintain the category colors. Outlook will assign the colors to each category. If you don't care about the color, this is not an issue. If you only have a few categories where the color matters, it's simple enough to change the colors yourself.

  1. Add all categories to an appointment, copy it to the calendar in the new mailbox, run the command to Upgrade to color categories.
  2. Use a macro to export a list of categories and a macro to import the list.
  3. Use MFCMAPI to export the categories.
  4. Use Powershell to export and import.

These scripts work with Outlook on your Windows Desktop. To use them, open the PowerShell ISE, paste the script (and edit) then Run. Tip: You can use the "regular" Powershell window, pasting the entire script in at once, but it's easier to edit the file path in the ISE editor.

  1. On the Windows Start menu, start typing powershell.
  2. When it comes up, click on Windows PowerShell ISE to open it.
    open the powershell ise
  3. Paste the desired script in the editor.
  4. Change the filepath and name as needed. You can save it as a CSV or txt file. Use double quotes around the name if it contains spaces.
  5. Click Run Script or F5 to run the script.
    run the powershell script

For these screenshots, I exported my categories then used the delete script to clear them before re-importing.
Color Categories before and after importing

Export Categories

These scripts create a simple comma-separated list containing the category name, color code, and shortcut. You can edit the list in NotePad before importing it into Outlook.

"Name","Color","ShortcutKey"
"Internet Orders","23","0"
"Newsletters","3","0"
"Outlook MVP","8","0"
"MVP","2","0"
"GTM","17","0"

Use this script to export the categories in the default account's mailbox.

$outlook = New-Object -ComObject Outlook.Application
$namespace = $outlook.GetNamespace("MAPI")
$namespace.categories | Select-Object -Property Name, Color, ShortCutKey | Export-Csv -Path D:\Categories.txt -NoTypeInformation -encoding utf8

Use this script if you have more than one account in your profile and want to export the categories from the non-default account. The folder picker dialog comes up - select the account name that you want to export.

$outlook = New-Object -ComObject Outlook.Application
$namespace = $outlook.GetNamespace("MAPI")
$namespace.PickFolder().Store.Categories | Select-Object -Property Name, Color, ShortCutKey | Export-Csv -Path D:\Categories.txt -NoTypeInformation -encoding utf8

Import Categories

These scripts import the categories from a text file. Note that if the category name exists, the script will return an error on that entry in the PowerShell window but will add any category that does not exist. If you want to change the category colors or shortcuts, you'll need to delete the categories first as the script will not update existing categories.

Use this script to Import categories into the default mailbox.

$outlook = New-Object -ComObject Outlook.Application
$namespace = $outlook.GetNamespace("MAPI")
Import-CSV "D:\Categories.txt" | 
ForEach-Object { 
    $namespace.Categories.Add($_.Name,$_.Color,$_.ShortCutKey) 
}

Use this script to Import the categories into the selected mailbox.
$outlook = New-Object -ComObject Outlook.Application
$namespace = $outlook.GetNamespace("MAPI")
$sourceStore = $namespace.PickFolder().store
Import-CSV "D:\Categories.txt" | 
ForEach-Object { 
   $sourceStore.Categories.Add($_.Name,$_.Color,$_.ShortCutKey)
}

Delete Categories

To delete categories from the list, first export the list then run it to remove all categories from the list. Because this script moves forward, you may need to run it a few times to remove all categories. If the list is in alphabetical order, fewer passes may be needed.

$outlook = New-Object -ComObject Outlook.Application
$namespace = $outlook.GetNamespace("MAPI")
Import-CSV "D:\Categories.txt" | 
ForEach-Object { 
    $namespace.Categories.Remove($_.Name)
}

Use this to delete the categories from a specific mailbox in your profile.
$outlook = New-Object -ComObject Outlook.Application
$source = $namespace.stores | 
Where-Object { $_.displayname –eq ‘alias@domain.com’}

Import-CSV "D:\Categories.txt" | 
ForEach-Object { 
  $source.Categories.Remove($_.Name)
}

Outlook Color Category names and index number

Beginning with Outlook 2019/365, Microsoft updated some of the category colors and their names.

ColorIndexColorIndex
Red1New: Gray
Old: Dark Gray
14
Orange2New: Dark Gray
Old: Black
15
Peach3Dark Red16
Yellow4Dark Orange17
New: Light Green
Old: Green
5New: Brown
Old: Dark Peach
18
New: Light Teal
Old: Teal
6New: Gold
Old: Dark Yellow
19
New: Lime Green
Old: Olive
7Dark Green20
Blue8New: Teal
Old: Dark Teal
21
New: Lavender
Old: Purple
9New: Green
Old: Dark Olive
22
New: Magenta
Old: Maroon
10New: Navy Blue
Old: Dark Blue
23
New: Light Gray
Old: Steel
11Dark Purple24
New: Steel
Old: Dark Steel
12New: Dark Pink
Old: Dark Maroon
25
New: Warm Gray
Old: Gray
13

More Information

Print a list of Outlook Categories and their Colors

Use PowerShell to Export and Import Categories was last modified: June 4th, 2020 by Diane Poremsky

Related Posts:

  • Use VBScript to Export or Import Categories
  • Create a List of Color Categories to Merge or Restore
  • Create new Outlook folders using PowerShell
  • Use PowerShell to Bulk Change Contacts

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Subscribe
Notify of
8 Comments
newest
oldest most voted
Inline Feedbacks
View all comments

Filip
September 24, 2019 3:19 pm

wow, Dianne, you are genius. I like VB scripting and I love Powershell so far I did not know Outlook object model works this simple in Poweshell. Works like a charm. One improvement you add -Encoding UTF8 to the Export-Csv because else it cripples the characters some countries may use. I hope I find more similar nice tricks. I wonder whether you can access user defined fields and whether there are caveats.... Have a nice day

1
0
Reply
Diane Poremsky
Author
Reply to  Filip
September 24, 2019 5:11 pm

There is a lot your can do with powershell - but also a lot you can't do, at least with fairly simple scripts like these.

0
0
Reply
Victor
November 11, 2022 6:00 am

Hi Diane, really great, I wanted to use the method with a "note" as described years ago by ExtendOffice, but found out you need complete access to Exchange when it is an Exchange account. This doesn't work in outlook.com. Your scripts imports it into the .ost !

0
0
Reply
Jim
December 3, 2020 1:58 pm

Hi, I see this works through Outlook, but why not just use Outlook itself, which is easier? MFCMAPI is fiddly and weird, but it's easier to teach to support staff than comobject scripting and doesn't error out when you clobber the defaults by pasting in the standards en masse. In order to set, support and maintain company-standard Categories for all Users, the ability to reach into the Exchange Mailbox & manipulate Color Categories there (e.g. to have a standard set of 20 and no others which all users use) is what Admins need. I do the color-category-setting part of the onboarding process now pretty-much the way you describe. It's the hardest part of my job, especially since I've scripted all the rest. I can *pull* categories all day long, and even have a script that warns me when the Users "tinker" with their Color Categories so I'll know to go fix them. Easy-peasy. Putting them in place in the first place? Replacing them when Users tinker? Not-so-much... Is there ANY WAY to reach directly (i.e. on the Exchange Server) into each Mailbox's \Calendar folder to the Associated Contents Table, IPM.Configuration.CategoryList item's PR_ROAMING_XMLSTREAM and set its contents to a standard set?… Read more »

0
0
Reply
Doron
June 17, 2020 2:14 pm

Hi Diane,
 
Thank you for the information.
I tried to import the category using your script as-is. I created the text file the same as your example and the only thing I have changed was the path with no luck. Hopefully I am missing something here.
 
Please see below the input and the error:
:
 
categories.txt is:
 

Name","Color","ShortcutKey"
"Internet Orders","23","0"
"Newsletters","3","0"
"Outlook MVP","8","0"
"MVP","2","0"
"GTM","17","0"
 
 
 
PS C:\Windows\system32> $outlook = New-Object -ComObject Outlook.Application
$namespace = $outlook.GetNamespace("MAPI") 
Import-CSV "G:\kill\outlook\categories.txt" | ForEach-Object { 
$namespace.Categories.Add($_.Name,$_.Color,$_.ShortCutKey) 
}
 
Import-CSV : Could not find file 'G:\kill\outlook\categories.txt'.
At line:3 char:1
+ Import-CSV "G:\kill\outlook\categories.txt" | ForEach-Object {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  + CategoryInfo     : OpenError: (:) [Import-Csv], FileNotFoundException
  + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.ImportCsvCommand
 
 
 
 

0
0
Reply
Diane Poremsky
Author
Reply to  Doron
April 29, 2021 10:38 am

It's saying the file path is wrong - assuming the path is correct, is it open in another product?
Import-CSV : Could not find file 'G:\kill\outlook\categories.txt'.

0
0
Reply
Nel
June 15, 2020 1:31 pm

Hi Diane I wonder is there any way I can copy a few custom calander views that includes conditional formatting to 300 users any advice appreciated.

0
0
Reply
Diane Poremsky
Author
Reply to  Nel
June 15, 2020 11:46 pm

You can export the views using mfcmapi, but importing them is probably going to be a problem - i don't think you can import using powershell to the exchange server (which would be the easiest way to do it.) I believe Redemption can import, but you need the mailbox open on your computer or redemption on all the computers.

0
0
Reply

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 30 Issue 29

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Jetpack plugin with Stats module needs to be enabled.
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
  • Import EML Files into New Outlook
  • Opening PST files in New Outlook
  • New Outlook: Show To, CC, BCC in Replies
  • Insert Word Document into Email using VBA
  • Delete Empty Folders using PowerShell
  • Warn Before Deleting a Contact
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Import EML Files into New Outlook

Opening PST files in New Outlook

New Outlook: Show To, CC, BCC in Replies

Insert Word Document into Email using VBA

Delete Empty Folders using PowerShell

Warn Before Deleting a Contact

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2025 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.

:wpds_smile::wpds_grin::wpds_wink::wpds_mrgreen::wpds_neutral::wpds_twisted::wpds_arrow::wpds_shock::wpds_unamused::wpds_cool::wpds_evil::wpds_oops::wpds_razz::wpds_roll::wpds_cry::wpds_eek::wpds_lol::wpds_mad::wpds_sad::wpds_exclamation::wpds_question::wpds_idea::wpds_hmm::wpds_beg::wpds_whew::wpds_chuckle::wpds_silly::wpds_envy::wpds_shutmouth:
wpDiscuz

Sign up for Exchange Messaging Outlook

Our weekly Outlook & Exchange newsletter (bi-weekly during the summer)






Please note: If you subscribed to Exchange Messaging Outlook before August 2019, please re-subscribe.

Never see this message again.

You are going to send email to

Move Comment