It is very important to comply with the CI/CD in an organization, which means, among other things, that new Word documents have to come with the right fonts, sizes and colors. To do this, replace the Normal.dotm file in the "C:\Users\%username%\AppData\Roaming\Microsoft\Templates" directory. In order to distribute the Normal.dotm file with Intune, I have prepared a PowerShell script, which you can easily distribute as a Win32 app with Intune.
Table of Contents
PowerShell to distribute the Normal.dotm
The script creates the template folder locally in the user's AppData and then copies the Normal.dotm into it. If the folder already exists, it doesn't matter.
After execution, the script creates a validation file, which is also in the AppData of the user and contains the version.
$PackageName = "Normal-template"
$Version = "1"
Start-Transcript -Path "$env:ProgramData\Microsoft\IntuneManagementExtension\Logs\$PackageName-install.log" -Force
try{
New-Item -Path "$env:APPDATA\Microsoft\Templates" -ItemType "Directory" -Force
Copy-Item 'Normal.dotm' -Destination "$env:APPDATA\Microsoft\Templates\" -Recurse -Force
New-Item -Path "$ENV:LOCALAPPDATA\_MEM\$PackageName" -ItemType "file" -Force -Value $Version
}catch{
Write-Host "_____________________________________________________________________"
Write-Host "ERROR"
Write-Host "$_"
Write-Host "_____________________________________________________________________"
}
Stop-Transcript
Code language: PowerShell (powershell)
Create and upload Win32 app
You need the current "Microsoft Win32 Content Prep Tool".
You then create the Intunewin file as follows, where the path is the location where the installation file and the package are located.
You will then find your install.intunewin file in the specified folder. For this, in turn, we now create a new Win32 app in the Endpoint Manager under "Apps > Windows" +Add.
Here you upload the create install.intunewin file and assign the name, the description, the publisher and optionally an icon.
In the program settings you store the two commands and the installation behavior "User".
install command | %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -executionpolicy bypass -command .\install.ps1 |
uninstall command | %SystemRoot%\sysnative\WindowsPowerShell\v1.0\powershell.exe -windowstyle hidden -executionpolicy bypass -command .\uninstall.ps1 |
You have to define something in the requirements, but there aren't any special ones.
As a "Detection Rule" I have prepared the file "check.ps1".
There are no dependencies and at the end you can still assign and create the package.
As soon as Intune installs the package, i.e. has replaced Normal.dotm, the user has the new Word template.
Attention: If you use special fonts in your template, these must also be installed on the device. I have documented how you can do this with Intune here: Install fonts with Intune
Update Normal.dotm
If you want to distribute a new version of Normal.dotm, you only have to increase the version in the second line in "install.ps1" and "check.ps1".
$PackageName = "Normal-template"
$Version = "1" # Change this number for updates
Code language: PowerShell (powershell)
Moin Florian,
in der uninstall.ps1 wird die NormalEmail.dotm gelöscht. Ist das ein Fehler?
oder kapier ich gerade nicht warum.
hast du ein "buy me a coffee"?
Grüße aus Spanien
Henning
Hallo Henning,
Vielen Dank für den Hinweis. Das war definitiv falsch und ist nun angepasst.
Zu "buy me a coffee", ab jetzt ja 🙂 https://www.buymeacoffee.com/scloud
Hey Florian,
bestimmt muss beim uninstall Befehl auch uninstall.ps1 aufgerufen werden und nicht install.ps1 oder?
Gruß Henning
Hallo Henning,
Ja genau.
Gruss Florian
Hey Florian,
was muss ich alles anpassen, wenn ich das auch für Excel und PowerPoint machen möchte? (Bezogen auf Pfade und Dateinamen, den Rest kriege ich hin)
Oder noch besser, hast du zufällig ein Script, in dem auch eine Excel und PowerPoint-Vorlage (quasi als Gesamtpaket) verteilt wird?
VG Gab
Hi Gab,
Leider gibt es bei PowerPoint und Excel keine Vorlage wie bei Word und Outlook.
Ich nutze dazu jeweils die Template Funktionalität von SharePoint. Damit hast du die Möglichkeit, beim Erstellen zwischen verschiedenen Vorlagen auszuwählen.
https://docs.microsoft.com/en-us/sharepoint/organization-assets-library
Reicht dir das so?
Beste Grüsse
Florian
Servus Florian,
ich weiß bloß, dass es bei PowerPoint eine default_theme punkt thmx-Datei gibt - daher meine Frage.
Bezüglich Excel habe ich auch nichts gefunden.
VG Gab
Hi Gab, just finished all office templates blogs and combined them in a summary: https://scloud.work/en/office-templates-sharepoint-intune/
Hello,
Thank for this, really helpful.
The installation is marked as failed although it is installed.
What could be the issue?
Perhaps something with the detection. Do you see the validation file with a version number in it?
Path: C:\Users\florian.salzmann\AppData\Local\4net\EndpointManager\Validation\Normal-template
We get this error 0x80070001 when trying to push it out.?
did you deploy the app in the sure context?
Hi Florian,
ich habe es versucht die Vorlage wird bei mir auch verteilt bedeutet sie ist unter dem Pfad zu finden aber leider erscheint es nicht in Word selbst.
hast du eine Idee ?
Hallo Lara, heisst die Vorlage "Normal.dotm" und hat auch das korrekte Format?
Hi, this is great! It works perfectly - with one strange exception.
The Normal template is installed (I see this when I open Word). Intune says the app is installed correctly. But: in the folder C:\Program Files\4net\EndpointManager\Validation there is no validation file.
I have not made any changes in any of the scripts, and I have uploaded (and double checked) the check.ps1 file to Intune.
Since everythnig works, I guess this will only be an issue when/if I want to update the template, but I find it strange (and a little annoying 🙂 )
I have also used your equally great tutorial on how to install company fonts. This also works perfectly, but in this case, the validation file "Company-Fonts" in the folder C:\Program Files\4net\EndpointManager\Validation is actually there, showing the correct version number.
Hi Marten, happy to hear the solutions work for you!
Regarding the Validation file, cause the Normal.dotm is in the User context, the validation file is as well.
You'll find it at:
C:\Users\%username%\AppData\Local\_MEM\Validation\Normal-template
Oh, thanks!
Hi,
I tried this method. Im getting error message ("The process cannot access the file 'C:\Users\intune.test1\AppData\Roaming\Microsoft\Templates\Normal.dotm' because it is being used by another process.")
Can you help me out this issue.
Thanks,
Mohan Thava
Looks like the Normal.dotm is in use while executing the script.
Word needs to be closed during the installation process.
Great article! it maybe good to note that the actual applications must be closed before the template can actually be replaced
getting this error message "Error code: 0x87D1041C"
Hi Florian, vielen Dank für den Artikel. Wenn ich zwei Vorlagen pushen will eine Dotm die andere als docx kann ich diese dann ganz gewöhnlich in ein paket packen und muss nur das script anpassen?
Dank Dir schonmal
Hallo, diese Anleitung bezieht sich nur auf die Standard-Vorlage und nicht auf die allgemeinen Vorlagen. Für die allgemeinen Vorlagen empfehle ich dir den Weg über SharePoint. Dort ersparst du dir auch das Umpacken, wenn eine neue Vorlage hinzukommt.
Den Artikel dazu findest du hier: https://scloud.work/de/office-vorlagen-sharepoint-intune/
super its working thnx
Thanks for this super blog post!
If i need to make changes to the normal.dotm file, do I have to make a new package and do everything all over?
Correct, you need to deploy a new version of the win32 package.