PowerShell script to change font of office apps

New Contributor
Hi,

We are using Microsoft 365 for Enterprise for delivery office apps to users via Microsoft Intune.

Currently the default font for all office apps is Calibri and now users want that it should change to Arial, 11 font.

Is there a way in Powershell to make that change.
I have been suggested ways to do it with .net objects or Interop.

Can someone please share a sample PowerShell script or a full script to make that change.

Thanks,
Ashish Arya
8 Replies

@ashisharya 

Hi Ashish,

 

are you able to clarify are you wanting to just change the default settings for new documents? or are you wanting to retro-fix existing documents as well?

 

If it's just changing the default settings for word/outlook then the easiest method is to update the Normal.dotx / NormalEmail.dotm file on a device and replace the versions on the rest of the devices with the updated ones...

 

quick steps for creation

1 - update Normal.dotx / NormalEmail.dotm and save to a folder

2 - create a PowerShell script to copy the above files to the correct location - you will want to include something in the script to write a file or a reg key that you can use in the detection rules in MEM

copy-item -path .\Normal.dotx -destination $env:Appdata\Microsoft\Templates -force
copy-item -path .\NormalEmail.dotm -destination $env:Appdata\Microsoft\Templates -force

3 - using the Microsoft Win32 Content Prep tool make an .intunewin containing the script and the new files

4 - upload to MEM as Win32 application and configure detection rules etc

5 - link Win32 Application to a device and test

 

if you are wanting to reto-fix existing documents then that becomes a bit more complex... I was trying to find the example for this that explained the process of doing this (came out around the same time they introduced the new file format). but basically the new office format documents are really just zip files containing XML files. styles.xml contains the document styles so this xml file could be pulled out of a document manually updated then write a PS script to loop through a document share etc, and open the file as an archive and inject this updated xml file.

 

hope that helps 

 

Regards

 

Steve:)

@SteveMacNZ 

 

Hi Steve, this is exactly what I am looking for to be able to change Outlook's default font on all of our organisations devices. Would you be able to provide more details of the PS script so I can replicate this on our machines? Any help would be greatly appreciated. Thanks Jason

@Jason275: Jason I have been able to achieve this by replacing my custom Normal.dotm file (stored at the Azure blob) with the default Normal.dotm file located at %appdata%\Microsoft\Templates (the default location of word and Outlook templates).

 

Below are the steps that I took for changing fonts for Word and same can be tried for Outlook as well.

 

1. I pushed out a PS script (Schdtask) from Intune to create a scheduled task on all Intune devices.

2. This task will run another PS script(LogonScript) stored at the same Azure blob whenever there is a user login.

2. This LogonScript will first remove the default Normal.dotm file.

3. Then it will then connect to the same Azure blob and get our custom Normal.dotm file and place it under the same default template location.

 

I am sure this is not the best solution to go with but this can be tried if you have no other choice.

 

I will also be keen to get any other solution for this.

 

Regards,

Ashish Arya

Another option would be to copy to the default profile which is copied each time a new user logs on - which would negate the need for the scheduled task...
Pulling from Azure Blob is a good idea - just make sure that you include the detection so it only downloads the file from Blob if it is changed

I must admit @Ashish_Arya I'm not really sure how to achieve this through your suggestion as I'm quite new to this.

@SteveMacNZI like the sound of your option but not sure where to find the default profile in the registry, I can only see the HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\16.0\Common\MailSettings. Any further help would be greatly appreciated. Thanks Jason

This is my script, it works when I run it locally but won't deploy when I roll it out through Intune:

cd HKCU:\SOFTWARE\Microsoft\Office\16.0\Common\MailSettings
Get-Item -path ./
Set-ItemProperty -path ./ -Name ‘NewTheme’ -Value ('')
Set-ItemProperty -path ./ -Name ‘MarkCommentsWith’ -Value ([byte[]](0x00,0x00))
Set-ItemProperty -path ./ -Name ‘ComposeFontComplex’ -Value ([byte[]](0x3c,0x68,0x74,0x6d,0x6c,0x3e,0x0d,0x0a,0x0d,0x0a,0x3c,0x68,0x65,0x61,0x64,0x3e,0x0d,0x0a,0x3c,0x73,0x74,0x79,0x6c,0x65,0x3e,0x0d,0x0a,0x0d,0x0a,0x20,0x2f,0x2a,0x20,0x53,0x74,0x79,0x6c,0x65,0x20,0x44,0x65,0x66,0x69,0x6e,0x69,0x74,0x69,0x6f,0x6e,0x73,0x20,0x2a,0x2f,0x0d,0x0a,0x20,0x73,0x70,0x61,0x6e,0x2e,0x50,0x65,0x72,0x73,0x6f,0x6e,0x61,0x6c,0x43,0x6f,0x6d,0x70,0x6f,0x73,0x65,0x53,0x74,0x79,0x6c,0x65,0x0d,0x0a,0x09,0x7b,0x6d,0x73,0x6f,0x2d,0x73,0x74,0x79,0x6c,0x65,0x2d,0x6e,0x61,0x6d,0x65,0x3a,0x22,0x50,0x65,0x72,0x73,0x6f,0x6e,0x61,0x6c,0x20,0x43,0x6f,0x6d,0x70,0x6f,0x73,0x65,0x20,0x53,0x74,0x79,0x6c,0x65,0x22,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x73,0x74,0x79,0x6c,0x65,0x2d,0x74,0x79,0x70,0x65,0x3a,0x70,0x65,0x72,0x73,0x6f,0x6e,0x61,0x6c,0x2d,0x63,0x6f,0x6d,0x70,0x6f,0x73,0x65,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x73,0x74,0x79,0x6c,0x65,0x2d,0x6e,0x6f,0x73,0x68,0x6f,0x77,0x3a,0x79,0x65,0x73,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x73,0x74,0x79,0x6c,0x65,0x2d,0x75,0x6e,0x68,0x69,0x64,0x65,0x3a,0x6e,0x6f,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x61,0x6e,0x73,0x69,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x73,0x69,0x7a,0x65,0x3a,0x31,0x30,0x2e,0x30,0x70,0x74,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x62,0x69,0x64,0x69,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x73,0x69,0x7a,0x65,0x3a,0x31,0x31,0x2e,0x30,0x70,0x74,0x3b,0x0d,0x0a,0x09,0x66,0x6f,0x6e,0x74,0x2d,0x66,0x61,0x6d,0x69,0x6c,0x79,0x3a,0x22,0x56,0x65,0x72,0x64,0x61,0x6e,0x61,0x22,0x2c,0x73,0x61,0x6e,0x73,0x2d,0x73,0x65,0x72,0x69,0x66,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x61,0x73,0x63,0x69,0x69,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x66,0x61,0x6d,0x69,0x6c,0x79,0x3a,0x56,0x65,0x72,0x64,0x61,0x6e,0x61,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x68,0x61,0x6e,0x73,0x69,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x66,0x61,0x6d,0x69,0x6c,0x79,0x3a,0x56,0x65,0x72,0x64,0x61,0x6e,0x61,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x62,0x69,0x64,0x69,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x66,0x61,0x6d,0x69,0x6c,0x79,0x3a,0x22,0x54,0x69,0x6d,0x65,0x73,0x20,0x4e,0x65,0x77,0x20,0x52,0x6f,0x6d,0x61,0x6e,0x22,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x62,0x69,0x64,0x69,0x2d,0x74,0x68,0x65,0x6d,0x65,0x2d,0x66,0x6f,0x6e,0x74,0x3a,0x6d,0x69,0x6e,0x6f,0x72,0x2d,0x62,0x69,0x64,0x69,0x3b,0x0d,0x0a,0x09,0x63,0x6f,0x6c,0x6f,0x72,0x3a,0x77,0x69,0x6e,0x64,0x6f,0x77,0x74,0x65,0x78,0x74,0x3b,0x7d,0x0d,0x0a,0x2d,0x2d,0x3e,0x0d,0x0a,0x3c,0x2f,0x73,0x74,0x79,0x6c,0x65,0x3e,0x0d,0x0a,0x3c,0x2f,0x68,0x65,0x61,0x64,0x3e,0x0d,0x0a,0x0d,0x0a,0x3c,0x2f,0x68,0x74,0x6d,0x6c,0x3e,0x0d,0x0a))
Set-ItemProperty -path ./ -Name ‘ComposeFontSimple’ -Value ([byte[]](0x3c,0x00,0x00,0x00,0x1f,0x00,0x00,0xf8,0x00,0x00,0x00,0x40,0xc8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x22,0x56,0x65,0x72,0x64,0x61,0x6e,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00))
Set-ItemProperty -path ./ -Name ‘ReplyFontComplex’ -Value ([byte[]](0x3c,0x68,0x74,0x6d,0x6c,0x3e,0x0d,0x0a,0x0d,0x0a,0x3c,0x68,0x65,0x61,0x64,0x3e,0x0d,0x0a,0x3c,0x73,0x74,0x79,0x6c,0x65,0x3e,0x0d,0x0a,0x0d,0x0a,0x20,0x2f,0x2a,0x20,0x53,0x74,0x79,0x6c,0x65,0x20,0x44,0x65,0x66,0x69,0x6e,0x69,0x74,0x69,0x6f,0x6e,0x73,0x20,0x2a,0x2f,0x0d,0x0a,0x20,0x73,0x70,0x61,0x6e,0x2e,0x50,0x65,0x72,0x73,0x6f,0x6e,0x61,0x6c,0x52,0x65,0x70,0x6c,0x79,0x53,0x74,0x79,0x6c,0x65,0x0d,0x0a,0x09,0x7b,0x6d,0x73,0x6f,0x2d,0x73,0x74,0x79,0x6c,0x65,0x2d,0x6e,0x61,0x6d,0x65,0x3a,0x22,0x50,0x65,0x72,0x73,0x6f,0x6e,0x61,0x6c,0x20,0x52,0x65,0x70,0x6c,0x79,0x20,0x53,0x74,0x79,0x6c,0x65,0x22,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x73,0x74,0x79,0x6c,0x65,0x2d,0x74,0x79,0x70,0x65,0x3a,0x70,0x65,0x72,0x73,0x6f,0x6e,0x61,0x6c,0x2d,0x72,0x65,0x70,0x6c,0x79,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x73,0x74,0x79,0x6c,0x65,0x2d,0x6e,0x6f,0x73,0x68,0x6f,0x77,0x3a,0x79,0x65,0x73,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x73,0x74,0x79,0x6c,0x65,0x2d,0x75,0x6e,0x68,0x69,0x64,0x65,0x3a,0x6e,0x6f,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x61,0x6e,0x73,0x69,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x73,0x69,0x7a,0x65,0x3a,0x31,0x30,0x2e,0x30,0x70,0x74,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x62,0x69,0x64,0x69,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x73,0x69,0x7a,0x65,0x3a,0x31,0x31,0x2e,0x30,0x70,0x74,0x3b,0x0d,0x0a,0x09,0x66,0x6f,0x6e,0x74,0x2d,0x66,0x61,0x6d,0x69,0x6c,0x79,0x3a,0x22,0x56,0x65,0x72,0x64,0x61,0x6e,0x61,0x22,0x2c,0x73,0x61,0x6e,0x73,0x2d,0x73,0x65,0x72,0x69,0x66,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x61,0x73,0x63,0x69,0x69,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x66,0x61,0x6d,0x69,0x6c,0x79,0x3a,0x56,0x65,0x72,0x64,0x61,0x6e,0x61,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x68,0x61,0x6e,0x73,0x69,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x66,0x61,0x6d,0x69,0x6c,0x79,0x3a,0x56,0x65,0x72,0x64,0x61,0x6e,0x61,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x62,0x69,0x64,0x69,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x66,0x61,0x6d,0x69,0x6c,0x79,0x3a,0x22,0x54,0x69,0x6d,0x65,0x73,0x20,0x4e,0x65,0x77,0x20,0x52,0x6f,0x6d,0x61,0x6e,0x22,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x62,0x69,0x64,0x69,0x2d,0x74,0x68,0x65,0x6d,0x65,0x2d,0x66,0x6f,0x6e,0x74,0x3a,0x6d,0x69,0x6e,0x6f,0x72,0x2d,0x62,0x69,0x64,0x69,0x3b,0x0d,0x0a,0x09,0x63,0x6f,0x6c,0x6f,0x72,0x3a,0x77,0x69,0x6e,0x64,0x6f,0x77,0x74,0x65,0x78,0x74,0x3b,0x7d,0x0d,0x0a,0x2d,0x2d,0x3e,0x0d,0x0a,0x3c,0x2f,0x73,0x74,0x79,0x6c,0x65,0x3e,0x0d,0x0a,0x3c,0x2f,0x68,0x65,0x61,0x64,0x3e,0x0d,0x0a,0x0d,0x0a,0x3c,0x2f,0x68,0x74,0x6d,0x6c,0x3e,0x0d,0x0a))
Set-ItemProperty -path ./ -Name ‘ReplyFontSimple’ -Value ([byte[]](0x3c,0x00,0x00,0x00,0x1f,0x00,0x00,0xf8,0x00,0x00,0x00,0x40,0xc8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x22,0x56,0x65,0x72,0x64,0x61,0x6e,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00))
Set-ItemProperty -path ./ -Name ‘TextFontComplex’ -Value ([byte[]](0x3c,0x68,0x74,0x6d,0x6c,0x3e,0x0d,0x0a,0x0d,0x0a,0x3c,0x68,0x65,0x61,0x64,0x3e,0x0d,0x0a,0x3c,0x73,0x74,0x79,0x6c,0x65,0x3e,0x0d,0x0a,0x0d,0x0a,0x20,0x2f,0x2a,0x20,0x53,0x74,0x79,0x6c,0x65,0x20,0x44,0x65,0x66,0x69,0x6e,0x69,0x74,0x69,0x6f,0x6e,0x73,0x20,0x2a,0x2f,0x0d,0x0a,0x20,0x70,0x2e,0x4d,0x73,0x6f,0x50,0x6c,0x61,0x69,0x6e,0x54,0x65,0x78,0x74,0x2c,0x20,0x6c,0x69,0x2e,0x4d,0x73,0x6f,0x50,0x6c,0x61,0x69,0x6e,0x54,0x65,0x78,0x74,0x2c,0x20,0x64,0x69,0x76,0x2e,0x4d,0x73,0x6f,0x50,0x6c,0x61,0x69,0x6e,0x54,0x65,0x78,0x74,0x0d,0x0a,0x09,0x7b,0x6d,0x73,0x6f,0x2d,0x73,0x74,0x79,0x6c,0x65,0x2d,0x6e,0x6f,0x73,0x68,0x6f,0x77,0x3a,0x79,0x65,0x73,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x73,0x74,0x79,0x6c,0x65,0x2d,0x70,0x72,0x69,0x6f,0x72,0x69,0x74,0x79,0x3a,0x39,0x39,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x73,0x74,0x79,0x6c,0x65,0x2d,0x6c,0x69,0x6e,0x6b,0x3a,0x22,0x50,0x6c,0x61,0x69,0x6e,0x20,0x54,0x65,0x78,0x74,0x20,0x43,0x68,0x61,0x72,0x22,0x3b,0x0d,0x0a,0x09,0x6d,0x61,0x72,0x67,0x69,0x6e,0x3a,0x30,0x63,0x6d,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x70,0x61,0x67,0x69,0x6e,0x61,0x74,0x69,0x6f,0x6e,0x3a,0x77,0x69,0x64,0x6f,0x77,0x2d,0x6f,0x72,0x70,0x68,0x61,0x6e,0x3b,0x0d,0x0a,0x09,0x66,0x6f,0x6e,0x74,0x2d,0x73,0x69,0x7a,0x65,0x3a,0x31,0x30,0x2e,0x30,0x70,0x74,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x62,0x69,0x64,0x69,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x73,0x69,0x7a,0x65,0x3a,0x31,0x30,0x2e,0x35,0x70,0x74,0x3b,0x0d,0x0a,0x09,0x66,0x6f,0x6e,0x74,0x2d,0x66,0x61,0x6d,0x69,0x6c,0x79,0x3a,0x22,0x56,0x65,0x72,0x64,0x61,0x6e,0x61,0x22,0x2c,0x73,0x61,0x6e,0x73,0x2d,0x73,0x65,0x72,0x69,0x66,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x66,0x61,0x72,0x65,0x61,0x73,0x74,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x66,0x61,0x6d,0x69,0x6c,0x79,0x3a,0x43,0x61,0x6c,0x69,0x62,0x72,0x69,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x66,0x61,0x72,0x65,0x61,0x73,0x74,0x2d,0x74,0x68,0x65,0x6d,0x65,0x2d,0x66,0x6f,0x6e,0x74,0x3a,0x6d,0x69,0x6e,0x6f,0x72,0x2d,0x6c,0x61,0x74,0x69,0x6e,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x62,0x69,0x64,0x69,0x2d,0x66,0x6f,0x6e,0x74,0x2d,0x66,0x61,0x6d,0x69,0x6c,0x79,0x3a,0x22,0x54,0x69,0x6d,0x65,0x73,0x20,0x4e,0x65,0x77,0x20,0x52,0x6f,0x6d,0x61,0x6e,0x22,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x62,0x69,0x64,0x69,0x2d,0x74,0x68,0x65,0x6d,0x65,0x2d,0x66,0x6f,0x6e,0x74,0x3a,0x6d,0x69,0x6e,0x6f,0x72,0x2d,0x62,0x69,0x64,0x69,0x3b,0x0d,0x0a,0x09,0x6d,0x73,0x6f,0x2d,0x66,0x61,0x72,0x65,0x61,0x73,0x74,0x2d,0x6c,0x61,0x6e,0x67,0x75,0x61,0x67,0x65,0x3a,0x45,0x4e,0x2d,0x55,0x53,0x3b,0x7d,0x0d,0x0a,0x2d,0x2d,0x3e,0x0d,0x0a,0x3c,0x2f,0x73,0x74,0x79,0x6c,0x65,0x3e,0x0d,0x0a,0x3c,0x2f,0x68,0x65,0x61,0x64,0x3e,0x0d,0x0a,0x0d,0x0a,0x3c,0x2f,0x68,0x74,0x6d,0x6c,0x3e,0x0d,0x0a))
Set-ItemProperty -path ./ -Name ‘TextFontSimple’ -Value ([byte[]](0x3c,0x00,0x00,0x00,0x1f,0x00,0x00,0xf8,0x00,0x00,0x00,0x40,0xc8,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0x00,0x22,0x56,0x65,0x72,0x64,0x61,0x6e,0x61,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00))

@Jason275 

 

Hi Jason - sorry about the slow reply - been tied up on projects.

 

When deploying registry settings via MEM (Intune) as a win32app the registry values are actually written to the WOW6432Node - as the win32apps scripts are run in 32bit PowerShell not in the native 64 bit.

 

Use this code below in the script to relaunch the script in a 64 bit console. Note: the SysNative path only exist when the 32bit session is running :)

# If we are running as a 32-bit process on an x64 system, re-launch as a 64-bit process
if ("$env:PROCESSOR_ARCHITEW6432" -ne "ARM64")
{
    if (Test-Path "$($env:WINDIR)\SysNative\WindowsPowerShell\v1.0\powershell.exe")
    {
        & "$($env:WINDIR)\SysNative\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy bypass -File "$PSCommandPath"
        Exit $lastexitcode
    }
}

 

@SteveMacNZ

Hi Steve, thank you so much for this! I can now successfully run the script and make the changes to the registry on all of the devices through MEM. Thanks again for all your help with this.