From 5f30e46f48b7e8341a8d847a82d26c3f537bbdf0 Mon Sep 17 00:00:00 2001 From: Paul Cunningham Date: Thu, 22 Sep 2016 15:09:22 +1000 Subject: [PATCH 01/10] Added initial script version --- Install-OfficeCTR.ps1 | 98 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) create mode 100644 Install-OfficeCTR.ps1 diff --git a/Install-OfficeCTR.ps1 b/Install-OfficeCTR.ps1 new file mode 100644 index 0000000..308d461 --- /dev/null +++ b/Install-OfficeCTR.ps1 @@ -0,0 +1,98 @@ +<# +.SYNOPSIS +Install-OfficeCTR.ps1 - Office 365 CTR Install Script + +.DESCRIPTION +This PowerShell script will install Office 365 Click-to-Run on +client computers. + +This script is designed to work with Office 2016 builds of +Office 365 CTR, not Office 2013. + +Before using this script you should set up an shared folder for +your Office 365 CTR deployments by following the instructions +at http://practical365.com + +.PARAMETER InstallRoot +Specify the UNC path to the network share that hosts the Office 365 +setup and configuration files. + +.PARAMETER OfficeVersion +Specify the Office CTR version to deploy (e.g. 2013, or 2016) + +.PARAMETER SKU +Specify the the Office CTR SKU to deploy (e.g. ProPlus, Business) + +.PARAMETER + +.EXAMPLE +.\Verb-NounsAndThings.ps1 +What does this example do... + +.NOTES +Written by: Paul Cunningham + +Find me on: + +* My Blog: http://paulcunningham.me +* Twitter: https://twitter.com/paulcunningham +* LinkedIn: http://au.linkedin.com/in/cunninghamp/ +* Github: https://github.com/cunninghamp + +For more Office 365 tips, tricks and news +check out Practical365. + +* Website: http://practical365.com +* Twitter: http://twitter.com/practical365 + +Change Log +V1.00, 22/09/2016 - Comment +#> + +#requires -version 4 + + +[CmdletBinding()] +param ( + + [Parameter(Mandatory=$true)] + [switch]$InstallRoot, + + [Parameter(Mandatory=$true)] + [ValidateSet('Business','ProPlus', ignorecase=$False)] + [string]$SKU, + + [Parameter(Mandatory=$false)] + [ValidateSet('Current','Deferred','FirstReleaseCurrent','FirstReleaseDeferred',ignorecase=$False)] + [string]$Channel + + ) + + +$ConfigurationXML = "$($InstallRoot)\$($SKU)\$($Channel)\configuration.xml" + +try { + Test-Path $ConfigurationXML -ErrorAction STOP +} +catch { + throw "Unable to locate a configuration XML file at $($ConfigurationXML)" +} + +$setuppath = "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe" +try { + +} +catch { + throw "Unable to locate a Setup.exe file at $($setuppath)" +} + +Write-Host "Attempting to install Office 365 $($SKU) $($Channel)" +$process = Start-Process -FilePath "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe" -ArgumentList "/Configure $($InstallRoot)\$($SKU)\$($Channel)\configuration.xml" -Wait -PassThru +if ($process.ExitCode -eq 0) +{ + Write-Host -ForegroundColor Green "Office setup started without error." +} +else +{ + Write-Warning "Installer exit code $($process.ExitCode)." +} From 4789ccd7516f216cfa2374f15dc5131966534ad9 Mon Sep 17 00:00:00 2001 From: Paul Cunningham Date: Thu, 22 Sep 2016 15:09:29 +1000 Subject: [PATCH 02/10] Added product ID reference --- ConfigurationXML/ProductIDs.md | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 ConfigurationXML/ProductIDs.md diff --git a/ConfigurationXML/ProductIDs.md b/ConfigurationXML/ProductIDs.md new file mode 100644 index 0000000..799ff7f --- /dev/null +++ b/ConfigurationXML/ProductIDs.md @@ -0,0 +1,11 @@ +#Office Click-to-Run Product IDs + +Source: (Microsoft)[https://support.microsoft.com/en-au/kb/2842297] + +The following product IDs are supported for use in Configuration.xml files with the Office Deployment Tool. + +|Product ID|Office 365 Plan| +|---|---| +|O365ProPlusRetail|Office ProPlus, Office 365 Enterprise E3, Office 365 Enterprise E5| +|O365BusinessRetail|Office 365 Business, Office 365 Business Premium| + From 021e7567731da68a9b3be9b059401d2647573c5f Mon Sep 17 00:00:00 2001 From: Paul Cunningham Date: Thu, 22 Sep 2016 15:10:38 +1000 Subject: [PATCH 03/10] Markdown fix --- ConfigurationXML/ProductIDs.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ConfigurationXML/ProductIDs.md b/ConfigurationXML/ProductIDs.md index 799ff7f..8a49817 100644 --- a/ConfigurationXML/ProductIDs.md +++ b/ConfigurationXML/ProductIDs.md @@ -1,6 +1,6 @@ #Office Click-to-Run Product IDs -Source: (Microsoft)[https://support.microsoft.com/en-au/kb/2842297] +Source: [Microsoft](https://support.microsoft.com/en-au/kb/2842297) The following product IDs are supported for use in Configuration.xml files with the Office Deployment Tool. From 92f1063e522ad1e0dfd254ba5ff0b699aabbcf68 Mon Sep 17 00:00:00 2001 From: Paul Cunningham Date: Thu, 22 Sep 2016 15:11:27 +1000 Subject: [PATCH 04/10] Renamed to readme --- ConfigurationXML/{ProductIDs.md => ReadMe.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename ConfigurationXML/{ProductIDs.md => ReadMe.md} (100%) diff --git a/ConfigurationXML/ProductIDs.md b/ConfigurationXML/ReadMe.md similarity index 100% rename from ConfigurationXML/ProductIDs.md rename to ConfigurationXML/ReadMe.md From 84df53b9553bfb2861cb977a609eba8fc2fea8f6 Mon Sep 17 00:00:00 2001 From: Paul Cunningham Date: Thu, 22 Sep 2016 15:13:53 +1000 Subject: [PATCH 05/10] Fixed parameter type --- Install-OfficeCTR.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Install-OfficeCTR.ps1 b/Install-OfficeCTR.ps1 index 308d461..f8be89e 100644 --- a/Install-OfficeCTR.ps1 +++ b/Install-OfficeCTR.ps1 @@ -56,7 +56,7 @@ V1.00, 22/09/2016 - Comment param ( [Parameter(Mandatory=$true)] - [switch]$InstallRoot, + [string]$InstallRoot, [Parameter(Mandatory=$true)] [ValidateSet('Business','ProPlus', ignorecase=$False)] From 49e6ae92685e942ab1f4982630e9530c1187c42c Mon Sep 17 00:00:00 2001 From: Paul Cunningham Date: Thu, 22 Sep 2016 15:17:02 +1000 Subject: [PATCH 06/10] Parameter validation made case insensitive --- Install-OfficeCTR.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Install-OfficeCTR.ps1 b/Install-OfficeCTR.ps1 index f8be89e..7107792 100644 --- a/Install-OfficeCTR.ps1 +++ b/Install-OfficeCTR.ps1 @@ -59,11 +59,11 @@ param ( [string]$InstallRoot, [Parameter(Mandatory=$true)] - [ValidateSet('Business','ProPlus', ignorecase=$False)] + [ValidateSet('Business','ProPlus', ignorecase=$true)] [string]$SKU, [Parameter(Mandatory=$false)] - [ValidateSet('Current','Deferred','FirstReleaseCurrent','FirstReleaseDeferred',ignorecase=$False)] + [ValidateSet('Current','Deferred','FirstReleaseCurrent','FirstReleaseDeferred',ignorecase=$true)] [string]$Channel ) From 70989f2c199b75365deb8cb892206061141c0f18 Mon Sep 17 00:00:00 2001 From: Paul Cunningham Date: Thu, 22 Sep 2016 15:20:19 +1000 Subject: [PATCH 07/10] Fixed error handling --- Install-OfficeCTR.ps1 | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/Install-OfficeCTR.ps1 b/Install-OfficeCTR.ps1 index 7107792..0791111 100644 --- a/Install-OfficeCTR.ps1 +++ b/Install-OfficeCTR.ps1 @@ -71,28 +71,30 @@ param ( $ConfigurationXML = "$($InstallRoot)\$($SKU)\$($Channel)\configuration.xml" -try { - Test-Path $ConfigurationXML -ErrorAction STOP -} -catch { +If (!(Test-Path $ConfigurationXML)) { throw "Unable to locate a configuration XML file at $($ConfigurationXML)" } $setuppath = "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe" -try { -} -catch { +if (!(Test-Path $setuppath)) { throw "Unable to locate a Setup.exe file at $($setuppath)" } Write-Host "Attempting to install Office 365 $($SKU) $($Channel)" -$process = Start-Process -FilePath "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe" -ArgumentList "/Configure $($InstallRoot)\$($SKU)\$($Channel)\configuration.xml" -Wait -PassThru -if ($process.ExitCode -eq 0) -{ - Write-Host -ForegroundColor Green "Office setup started without error." + +try { + $process = Start-Process -FilePath "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe" -ArgumentList "/Configure $($InstallRoot)\$($SKU)\$($Channel)\configuration.xml" -Wait -PassThru -ErrorAction STOP + + if ($process.ExitCode -eq 0) + { + Write-Host -ForegroundColor Green "Office setup started without error." + } + else + { + Write-Warning "Installer exit code $($process.ExitCode)." + } } -else -{ - Write-Warning "Installer exit code $($process.ExitCode)." +catch { + Write-Warning $_.Exception.Message } From 5e6326adbc27489b2e0f503a71cd4a8d14a4cadd Mon Sep 17 00:00:00 2001 From: Paul Cunningham Date: Thu, 22 Sep 2016 15:21:09 +1000 Subject: [PATCH 08/10] Changed Channel parameter to mandatory --- Install-OfficeCTR.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Install-OfficeCTR.ps1 b/Install-OfficeCTR.ps1 index 0791111..5e2c716 100644 --- a/Install-OfficeCTR.ps1 +++ b/Install-OfficeCTR.ps1 @@ -62,7 +62,7 @@ param ( [ValidateSet('Business','ProPlus', ignorecase=$true)] [string]$SKU, - [Parameter(Mandatory=$false)] + [Parameter(Mandatory=$true)] [ValidateSet('Current','Deferred','FirstReleaseCurrent','FirstReleaseDeferred',ignorecase=$true)] [string]$Channel From 7349e002ab58bf5e5cf982e029f715980ccb5510 Mon Sep 17 00:00:00 2001 From: Paul Cunningham Date: Tue, 4 Oct 2016 16:54:50 +1000 Subject: [PATCH 09/10] Updated readme --- README.md | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 2954d81..ec9bb39 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,58 @@ -# Office-365-Deploy -Office 365 Client Deployment Scripts +#Office 365 Client Deployment Scripts + +This repository hosts PowerShell scripts that assist with the deployment of Office 365 client software. + +The scripts included at this time are: + +- Install-OfficeCTR.ps1 + +If you're looking for more complex, featured scripts you might be interested in [Microsoft's Office Deployment Scripts for IT Pros](http://officedev.github.io/Office-IT-Pro-Deployment-Scripts/). + +##Install-OfficeCTR.ps1 - Office 365 CTR Install Script + +This PowerShell script will install Office 365 Click-to-Run when it is run manually, or as a logon/startup script. Install-OfficeCTR.ps1 supports both the ProPlus and Business SKU for Office 365, as well as the four channels: + +- Deferred +- Current +- First Release Deferred +- First Release Current + +This script is designed to work with Office 2016 builds of Office 365 CTR, not Office 2013. + +Before using this script you should set up an shared folder for your Office 365 CTR deployments by following the instructions at [Practical 365](https://practical365.com). + +###Usage: + +Install-OfficeCTR.ps1 uses the following parameters: + +- **InstallRoot** - Specify the UNC path to the network share that hosts the Office 365 +setup and configuration files. +- **SKU** - Specify the the Office CTR SKU to deploy (e.g. ProPlus, Business) +- **Channel** - Specify the build channel to deploy (e.g. Current, Deferred) + +The three parameters are used by the install script to locate the appropriate setup and configuration files in your install share on the network. + +Example: + +``` +.\Install-OfficeCTR.ps1 -InstallRoot \\mgmt\Installs\OfficeCTR -SKU ProPlus -Channel Deferred +``` + +The example above will look for setup and configuration files in **\\\mgmt\Installs\OfficeCTR\ProPlus\Deferred** + + + +##Credits +Written by: Paul Cunningham + +Find me on: + +* My Blog: http://paulcunningham.me +* Twitter: https://twitter.com/paulcunningham +* LinkedIn: http://au.linkedin.com/in/cunninghamp/ +* Github: https://github.com/cunninghamp + +For more Office 365 tips, tricks and news check out Practical 365. + +* Website: [http://practical365.com]() +* Twitter: [http://twitter.com/practical365]() \ No newline at end of file From b2b75702f3f5de91b93d570b1b97a0e78a51b56d Mon Sep 17 00:00:00 2001 From: Paul Cunningham Date: Tue, 4 Oct 2016 16:55:15 +1000 Subject: [PATCH 10/10] Added logic to skip when Office is already installed --- Install-OfficeCTR.ps1 | 86 ++++++++++++++++++++++++++++--------------- 1 file changed, 57 insertions(+), 29 deletions(-) diff --git a/Install-OfficeCTR.ps1 b/Install-OfficeCTR.ps1 index 5e2c716..c38fec2 100644 --- a/Install-OfficeCTR.ps1 +++ b/Install-OfficeCTR.ps1 @@ -17,17 +17,14 @@ at http://practical365.com Specify the UNC path to the network share that hosts the Office 365 setup and configuration files. -.PARAMETER OfficeVersion -Specify the Office CTR version to deploy (e.g. 2013, or 2016) - .PARAMETER SKU Specify the the Office CTR SKU to deploy (e.g. ProPlus, Business) -.PARAMETER +.PARAMETER Channel +Specify the build channel to deploy (e.g. Current, Deferred) .EXAMPLE -.\Verb-NounsAndThings.ps1 -What does this example do... +.\Install-OfficeCTR.ps1 -InstallRoot \\mgmt\Installs\OfficeCTR -SKU ProPlus -Channel Deferred .NOTES Written by: Paul Cunningham @@ -69,32 +66,63 @@ param ( ) -$ConfigurationXML = "$($InstallRoot)\$($SKU)\$($Channel)\configuration.xml" +function DoInstall { -If (!(Test-Path $ConfigurationXML)) { - throw "Unable to locate a configuration XML file at $($ConfigurationXML)" -} + $ConfigurationXML = "$($InstallRoot)\$($SKU)\$($Channel)\configuration.xml" -$setuppath = "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe" - -if (!(Test-Path $setuppath)) { - throw "Unable to locate a Setup.exe file at $($setuppath)" -} - -Write-Host "Attempting to install Office 365 $($SKU) $($Channel)" - -try { - $process = Start-Process -FilePath "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe" -ArgumentList "/Configure $($InstallRoot)\$($SKU)\$($Channel)\configuration.xml" -Wait -PassThru -ErrorAction STOP - - if ($process.ExitCode -eq 0) - { - Write-Host -ForegroundColor Green "Office setup started without error." + If (!(Test-Path $ConfigurationXML)) { + throw "Unable to locate a configuration XML file at $($ConfigurationXML)" } - else - { - Write-Warning "Installer exit code $($process.ExitCode)." + + $setuppath = "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe" + + if (!(Test-Path $setuppath)) { + throw "Unable to locate a Setup.exe file at $($setuppath)" + } + + Write-Host "Attempting to install Office 365 $($SKU) $($Channel)" + + try { + $process = Start-Process -FilePath "$($InstallRoot)\$($SKU)\$($Channel)\Setup.exe" -ArgumentList "/Configure $($InstallRoot)\$($SKU)\$($Channel)\configuration.xml" -Wait -PassThru -ErrorAction STOP + + if ($process.ExitCode -eq 0) + { + Write-Host -ForegroundColor Green "Office setup started without error." + } + else + { + Write-Warning "Installer exit code $($process.ExitCode)." + } + } + catch { + Write-Warning $_.Exception.Message + } + +} + +#Check if Office is already installed, as indicated by presence of registry key +$RegistryPath = 'HKLM:\SOFTWARE\Microsoft\Office\16.0\ClickToRunStore\Packages\{9AC08E99-230B-47e8-9721-4577B7F124EA}' + +if (Test-Path $RegistryPath) { + #Check for children + + $Item = Get-ItemProperty -Path $RegistryPath + + if (!($Item.'(default)' -eq $null)) { + #Office is installed, according to registry key. Nothing further to do. + EXIT + } + else { + #Registry key exists but default value is empty, install needed + DoInstall } } -catch { - Write-Warning $_.Exception.Message +else { + #Registry key doesn't exist, install needed + DoInstall } + + + + +