How to install Office using a Provisioning Package


Hi everyone,

Sorry, it took me quite a while to write that article about how to install Office using a Provisioning Package (PPKG).

As you might know, there’s some challenges deploying  a Win32 apps using PPKG because of the limitation of the file you can upload inside a PPKG to use with “ProvisioningCommands” feature. Indeed, it’s not currently possible to have a folder structure within the “CommandFiles” field; only files, not folders. This makes importing Office sources a big challenge since Office has a quite deep folder structure.

Fortunately there’s a workaround for that!


Let me show you how to install Office using PPKG and in the below explanation, i will use the Click-to-Run version of Office 2016 but it would work the same for Office 2016 Professional Plus (you might have to modify the PowerShell script to reflect the correct installation command line).

Creating the ZIP file containing Office source

The first thing you need to do is downloading the source of Office 2016 Click-to-Run and to do that, you need a free tool called “Office 2016 Deployment Tool” that you can download here.

  • Create a folder named “C:\O365” on the computer where you installed Windows ICD
  • Extract the Office Deployment Tool inside “C:\O365” folder.
  • Edit the “Configuration.xml” file using Notepad. I put an example below.
<Configuration>
  <Add SourcePath="" OfficeClientEdition="32" Branch="Current">
    <Product ID="O365ProPlusRetail">
      <Language ID="en-us" />
    </Product>
  </Add>
  <!--  <Updates Enabled="TRUE" Branch="Current" /> -->
  <Display Level="None" AcceptEULA="TRUE" />
  <Logging Level="Standard" Path="C:\Windows\Debug" />
  <!--  <Property Name="AUTOACTIVATE" Value="1" />  -->
</Configuration>
  • Open a Command Prompt and run the following command to download Office source.
    C:\O365\setup.exe /download configuration.xml
    • That will download Office source inside “C:\O365” folder
  • ZIP the “C:\O365” folder into a file called “O365.zip

Create the PowerShell script to install silently Office

  • Copy the sample code below and save it into a file called “Start-ProvisioningCommands.ps1
<#
.Synopsis
 Office 2016 installation sample script
.DESCRIPTION
 Extract the ZIP and run the Office setup.exe with the configuration file as a parameter
#>
[CmdletBinding()]
[Alias()]
[OutputType([int])]

Param
(
 [Parameter(Mandatory=$false,
 ValueFromPipelineByPropertyName=$true,
 Position=0)]
 $Log = "$env:windir\debug\Start-ProvisioningCommands.log"
)

Begin
{
 <#
 # Start logging
 #>
 Start-Transcript -Path $Log -Force -ErrorAction SilentlyContinue

<#
 # Extract the ZIP
 #> 
 $Archives = Get-ChildItem -Path $PSScriptRoot -Filter *.zip | Select-Object -Property FullName
 ForEach-Object -InputObject $Archives -Process { Expand-Archive -Path $_.FullName -DestinationPath "$env:TEMP" -Force }
}

Process
{
 <#
 # Office 2016 installation
 #> 
 $WorkingDirectory = "$env:TEMP\O365"
 $Configuration = Get-ChildItem -Path $WorkingDirectory -Filter *.xml | Select-Object -Property FullName
 [XML]$XML = Get-Content -Path $Configuration.FullName
 $XML.Configuration.Add.SourcePath = $WorkingDirectory
 $XML.Save($Configuration.FullName)

 # Run Office 2016 setup.exe
 Start-Process -FilePath "$WorkingDirectory\Setup.exe" -ArgumentList ('/Configure "{0}"' -f $Configuration.FullName) -WorkingDirectory $WorkingDirectory -Wait -WindowStyle Hidden

 # If you want to remove the extracted Office source, uncomment below
 # Remove-Item -Path $WorkingDirectory -Force
}
End
{
 <#
 # Stop logging
 #> 
 Stop-Transcript -ErrorAction SilentlyContinue
}

Create the Provisioning Package using Windows ICD

  • Open Windows ICD and navigate to [Runtime Settings]>[ProvisioningCommands]>[DeviceContext]
    • Under [CommandFiles] add “O365.zip” and “Start-ProvisioningCommands.ps1” files
    • Under [CommandLine], type the following command which will install silently Office:
      PowerShell.exe –ExecutionPolicy Unrestricted .\Start-ProvisioningCommands.ps1

You should get something which look like this:

WICDPPKG1

Create the PPKG and voila 🙂

PS: I want to thank my coworker Ryan Hall working as a Senior PFE in Australia who explained me that method to deploy Office using PPKG.

Comments (14)

  1. Excellent, worked like a charm!
    keep up the good work, i owe you a drink if/when you come to Paris for such a great support.
    and…it’s time to go to sleep ain’t it over there?

    thanks a lot!

    Best regards,

    Pierre.

    1. Happy that it helped 🙂

  2. Jakob_redtoo says:

    Are there any logfiles for troubleshooting?

    1. You will find the logs of the PS script here “$Log = “$env:windir\debug\Start-ProvisioningCommands.log””
      There’s unfortunately no log existing for PPKG execution so you will have to rely on the logs you create within your script.

  3. Ezzedeen Saghier says:

    Thank you.
    How it comes with Office 2016 Plus?
    What changes should I make?

    1. If you want to deploy Office 2016 Pro Plus, then you get the VL media of Office. You will first have to create your own configuration file which is a bit different from O365 one (you should file an example in the source).

      Then the command line to install Office 2016 Pro Plus is also a bit different. Instead of “setup.exe /Configure “, you will have to use “setup.exe /config “.

      So you will just have to change the following line in the script:
      Start-Process -FilePath “$WorkingDirectory\Setup.exe” -ArgumentList (‘/config “{0}”‘ -f $Configuration.FullName) -WorkingDirectory $WorkingDirectory -Wait -WindowStyle Hidden

  4. Kyle says:

    I am missing the ProvisioningCommands option from windows icd, what might I be missing?

    1. If you miss the ProvisioningCommands options in WICD, it means your ICD version is not the latest 1511 but the RTM version (10240).
      You should download the latest Windows ADK then you will get the ProvisioningCommands option 🙂

  5. slama Nabil says:

    Hi Samir,
    What do I have to change in your Powershell script for Office 2016 Professional Plus. I’m a beginner in Powershell and I don’t know what to modify in your script to work with Office 2016 Professional Plus ?

    1. I already answered to the same question 2 comments before 🙂

      So you will just have to change the following line in the script:
      Start-Process -FilePath “$WorkingDirectory\Setup.exe” -ArgumentList (‘/config “{0}”‘ -f $Configuration.FullName) -WorkingDirectory $WorkingDirectory -Wait -WindowStyle Hidden

      The configuration file for Office 2016 Pro Plus is a bit different from the one from Office 2016 click-to-run. You will find an exemple of config file in the following site: http://richardjgreen.net/unattended-installation-of-office-2016/

      1. slama Nabil says:

        Thank you very much, it’s working for me.

  6. Lewis Strecker says:

    Hi Samir Hammoudi

    I am a beginner in creating ICD provisional packages and are looking to implement your solution, however, when i run the command in command line i get an error for office, it says that the file could not be installed.
    Could you please advise, thank you in advance

Skip to main content