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.
You don’t need to create a program, just select “Do not create a program” and click next, and just go on and finish the wizard.
Here is two ways to use this.
The first one, if you boot your PC’s from a boot-media (CD/USB), you can create a new boot-media and put in a prestart command to run diskpart. So go one and create a new Task Sequence Media if you choose this way.
Mark Boot media, and Next
Continue the wizard, entering your “SCCM-info” till you come to Customize the task sequence media.
Here you will need to tick the Enable prestart command checkbox, and also enter Command line:
cmd.exe /c diskpart /s uefi_disk.txt <– or the name you gave your .txt-file
You must also select the Diskpart package you created earlier, and point out your Distribution point.
After that, finish the wizard, and you are now ready to boot using your new boot-media.
And diskpart will run
After diskpart is finished, you can choose your TS, and continue your installation
