Updated: Microsoft 365 Apps
This is a refresh of my old post Microsoft 365 Apps (Office 365) hantering i MECM (SCCM), or maybe I should write “a refresh of the script”.
In this post, I ensure that the Office Deployment Tool (ODT) is the latest version to support new version/function of Microsoft 365 Apps setup.
I use a modified Powershell script created by Marco Hofmann & Trond Eric Haavarstein to suit my idea.
Original script: https://www.meinekleinefarm.net/download-and-install-latest-office-365-deployment-tool-odt
What this version of the script does:
Download the latest version of the Office Deployment Tool (ODT).
Checks if it’s a newer version of the Office 365 Deployment Tool (ODT), and if it’s a newer version, extracts it to a subfolder with the version number as the folder name. If it is not a newer version, skips this step
Then copies the new setup.exe to both the folder for the source files and the application package in ConfigMgr
And for last it runs the setup.exe (with download xml-file) to download allt the Microsoft 365 Apps
<#
.SYNOPSIS
Download latest Office Deployment Tool (ODT) and Office setup files
.DESCRIPTION
Download latest Office Deployment Tool (ODT), extract setup.exe and download Office setup-files.
.EXAMPLE
PS:> \\DFSSHARE.ORGANISATION.ORG\...\download.ps1
Downloads latest officedeploymenttool.exe
Creates a sub-directory for each new version
Copies the setup.exe from the sub-directory to source-directory (incl. cmsetup-directory) and download Office setup-files
.NOTES
Author: Magnus Bäcke
URL: https://backes.nu
Original Author: Marco Hofmann and Trond Eric Haavarstein Original Author URL: https://www.meinekleinefarm.net and https://xenappblog.com/
This is the original script: https://www.meinekleinefarm.net/download-and-install-latest-office-365-deployment-tool-odt
.LINK
https://www.microsoft.com/en-us/download/details.aspx?id=49117
#>
$StartDTM = (Get-Date)
$LogDTM = (Get-Date -format "yyyy-MM-dd_HH-mm-ss")
$ODTDownload = "\\DFSSHARE.ORGANISATION.ORG\Office365SetupFiles$\ODTDownload\" # <-- You need to change the path
$LogPS = "\\DFSSHARE.ORGANISATION.ORG\Office365SetupFiles$\Logs\$LogDTM.log" # <-- You need to change the path
$SourcePath = "\\DFSSHARE.ORGANISATION.ORG\Office365SetupFiles$\" # <-- You need to change the path
$SetupPath = "\\DFSSHARE.ORGANISATION.ORG\CMSourceFiles$\Applications\Microsoft 365\Files\" # <-- You need to change the path
$Downloadxml = 'download.xml' # <-- You need to change this to the name of your Office download XML-file here, or name your XML-file download.xml
<# No need for any changes below here#>
$DownloadURL = (Invoke-WebRequest -Uri "https://www.microsoft.com/en-us/download/confirmation.aspx?id=49117").Links | Where-Object href -like '*exe' | select -First 1 | select -expand href
$SaveDir = "$ODTDownload\officedeploymenttool.exe"
$ProgressPreference = 'SilentlyContinue'
Set-Location $ODTDownload
Write-Verbose "Setting Arguments" -Verbose
Start-Transcript $LogPS
Write-Verbose "Download latest version of Office Deployment Tool (ODT)." -Verbose
Invoke-WebRequest -Uri $DownloadURL -OutFile $SaveDir
Write-Verbose "Read version number from downloaded file" -Verbose
$Version = (Get-Command .\officedeploymenttool.exe).FileVersionInfo.FileVersion
Write-Verbose "If downloaded ODT file is newer, create new sub-directory." -Verbose
if( -Not (Test-Path -Path $Version ) ) {
New-Item -ItemType directory -Path $Version
Write-Verbose "Extract setup.exe from ODT" -Verbose
.\officedeploymenttool.exe /quiet /extract:.\$Version
start-sleep -s 5
Write-Verbose "New folder created $Version" -Verbose
Set-Location $Version
Copy-item ".\setup.exe" -Destination $SourcePath -Force
Write-Verbose "setup-exe copied from $Version to $SourcePath " -Verbose
Copy-item ".\setup.exe" -Destination $SetupPath -Force
Write-Verbose "setup-exe copied from $Version to $SetupPath (CM O365 setup Source files)" -Verbose
}
else {
Write-Verbose "Version identical. Skipping folder creation." -Verbose
}
Set-Location $SourcePath
Write-Verbose "Downloading Office setup-files according to the XML-file." -Verbose
Start-Process ".\setup.exe" -ArgumentList "/download $Downloadxml" -Wait -PassThru
start-sleep -s 15
Write-Verbose "Stop logging" -Verbose
$EndDTM = (Get-Date)
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose
Stop-Transcript
Idéa: Use Task Scheduler to run this late on the second tuesday (or early on the second wednesday) in the month to always have the latest Apps downloaded.
Microsoft 365 Apps (Office 365) hantering i MECM (SCCM)
New updated post: Updated: Microsoft 365 Apps
Kör även denna bloggning på svenska (English by Google).
I min tidigare bloggpost, Office 365 ProPlus (Microsoft 365 Apps) hantering i SCCM (MECM) skrev jag om mitt sätt att säkerställa att samtliga Applikationspaket för Office 365 ProPlus, Visio Pro for Office 365, och Project Online Desktop Client alltid är av senast verifierad (godkänd för installation) version.
I denna bloggning så tar jag steget lite längre. Här ser jag även till att Office Deployment Tool (ODT) är i senaste version för att stödja installationen av den nya versionen av Office.
Jag har modifierat ett Powershell-script som Marco Hofmann & Trond Eric Haavarstein har skapat, så att det passar min idé.
Original scriptet: https://www.meinekleinefarm.net/download-and-install-latest-office-365-deployment-tool-odt
Det min version av scriptet gör:
- Laddar ner senaste versionen av Office 365 Deployment Tool (ODT)
- Kontrollerar om det är en nyare version av Office 365 Deployment Tool (ODT), och om det är en nyare version så Installeras den till en undermapp med versionsnummer som mappnamn. Är det inte en nyare version så hoppas steget över
- Kopierar sedan den nya setup.exe till både mappen för källfilerna samt applikationspaketet i CM
- Och till sist körs setup.exe /download download.xml för att ladda ner alla källfilerna
För att automatiserat detta kan man lägga in det i en schemalagd aktivitet.
Uppdatering 20211114: Ändrar $StartDTL = (Get-Date) till $StartDTL = (Get-Date -format “yyyyMMdd”) vilket ger en bättre sökväg till logfilen, efter tips av @sundstrom_lars.
<#
.SYNOPSIS
Download and install latest Office 365 Deployment Tool (ODT)
.DESCRIPTION
Download and install latest Office 365 Deployment Tool (ODT)
.EXAMPLE
PS:> \\DFSSHARE.ORGANISATION.ORG\...\download.ps1
Downloads latest officedeploymenttool.exe
Creates a sub-directory for each new version
Copies the setup.exe from the sub-directory to source-directory and cmsetup-directory
.NOTES
Author: Magnus Bäcke
URL: https://backes.nu
Original Author: Marco Hofmann & Trond Eric Haavarstein
Original Author URL: https://www.meinekleinefarm.net & https://xenappblog.com/
.LINK # This is the original script
Download and install latest Office 365 via Office Deployment Tool (ODT)
.LINK
https://www.microsoft.com/en-us/download/details.aspx?id=49117
.LINK
https://www.microsoft.com/en-us/download/confirmation.aspx?id=49117
#>
$StartDTL = (Get-Date -format "yyyyMMdd")
$ODTDownload = "\\DFSSHARE.ORGANISATION.ORG\Office365SetupFiles$\ODTDownload\"
$Vendor = "Microsoft"
$Product = "Office 365 x64"
$PackageName = "setup"
$InstallerType = "exe"
$LogPS = "\\DFSSHARE.ORGANISATION.ORG\Office365SetupFiles$\Logs\$StartDTM $Product $Version ODTDownload.log"
$SourcePath = "\\DFSSHARE.ORGANISATION.ORG\Office365SetupFiles$\"
$SetupPath = "\\DFSSHARE.ORGANISATION.ORG\CMSourceFiles$\Applikations\Microsoft Office 365\Files\"
$Downloadxml = 'download.xml'
$URL = $(Get-ODTUri)
$ProgressPreference = 'SilentlyContinue'
Set-Location $ODTDownload
function Get-ODTUri {
<#
.SYNOPSIS
Get Download URL of latest Office 365 Deployment Tool (ODT).
.NOTES
Author: Bronson Magnan
Twitter: @cit_bronson
Modified by: Marco Hofmann
Twitter: @xenadmin
.LINK
https://www.meinekleinefarm.net/
#>
[CmdletBinding()]
[OutputType([string])]
param ()
$url = "https://www.microsoft.com/en-us/download/confirmation.aspx?id=49117"
try {
$response = Invoke-WebRequest -UseBasicParsing -Uri $url -ErrorAction SilentlyContinue
}
catch {
Throw "Failed to connect to ODT: $url with error $_."
Break
}
finally {
$ODTUri = $response.links | Where-Object {$_.outerHTML -like "*click here to download manually*"}
Write-Output $ODTUri.href
}
}
Write-Verbose "Setting Arguments" -Verbose
Start-Transcript $LogPS
Write-Verbose "Download latest version of Office 365 Deployment Tool (ODT)." -Verbose
Invoke-WebRequest -UseBasicParsing -Uri $url -OutFile .\officedeploymenttool.exe
Write-Verbose "Read version number from downloaded file" -Verbose
$Version = (Get-Command .\officedeploymenttool.exe).FileVersionInfo.FileVersion
Write-Verbose "If downloaded ODT file is newer, create new sub-directory." -Verbose
if( -Not (Test-Path -Path $Version ) ) {
New-Item -ItemType directory -Path $Version
Write-Verbose "Extract setup.exe from ODT" -Verbose
.\officedeploymenttool.exe /quiet /extract:.\$Version
start-sleep -s 5
Write-Verbose "New folder created $Version" -Verbose
Set-Location $Version
Copy-item ".\setup.exe" -Destination $SourcePath -Force
Write-Verbose "setup-exe copied from $Version to $SourcePath " -Verbose
Copy-item ".\setup.exe" -Destination $SetupPath -Force
Write-Verbose "setup-exe copied from $Version to $SetupPath (CM O365 setup Source files)" -Verbose
}
else {
Write-Verbose "Version identical. Skipping folder creation." -Verbose
}
Set-Location $SourcePath
Write-Verbose "Downloading Office setup-files according to the XML-file." -Verbose
Start-Process ".\setup.exe" -ArgumentList "/download $Downloadxml" -Wait -PassThru
start-sleep -s 15
Set-Location $ODTDownload
Write-Verbose "Stop logging" -Verbose
$EndDTM = (Get-Date)
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalSeconds) Seconds" -Verbose
Write-Verbose "Elapsed Time: $(($EndDTM-$StartDTM).TotalMinutes) Minutes" -Verbose
Stop-Transcript