From 4b740b06e8c5409c3ab20d1f64430831137c9c23 Mon Sep 17 00:00:00 2001 From: David Yoder Date: Tue, 6 Aug 2024 11:27:46 -0400 Subject: [PATCH] initial commit --- Install-MicrosoftOffice365.ps1 | 71 ++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Install-MicrosoftOffice365.ps1 diff --git a/Install-MicrosoftOffice365.ps1 b/Install-MicrosoftOffice365.ps1 new file mode 100644 index 0000000..83235fd --- /dev/null +++ b/Install-MicrosoftOffice365.ps1 @@ -0,0 +1,71 @@ +# $COMPANY must be supplied by RMM +$PRODUCT = 'O365ProPlusRetail' +$BITNESS = '64' +$MIGARCH = 'TRUE' +$CHANNEL = 'SemiAnnual' +$UPDATES = 'TRUE' +$DISPLAY = 'Full' # "None", "Full" +$ACCEULA = 'TRUE' + +# Make changes if the system is 32bit +If ( !(Is64Bit) ) { $BITNESS = '32'; $MIGARCH = 'FALSE' } + +$CONFIG = @" + + + + + + + + + + + + + + + + + + + + +"@ + +# Set path to temp directory +$TEMPDIR = '{0}microsoft-office-deployment' -f (Get-TempPath) + +# Recursively delete $TEMPDIR if it already exists +If ( Test-Path $TEMPDIR ) { + Write-Output """${TEMPDIR}"" already exists and will be deleted" + Try { Remove-Item -Path $TEMPDIR -Recurse -Force -ErrorAction SilentlyContinue } + Catch { Write-Error $_.Exception.Message } +} + +# Create $TEMPDIR +Write-Output "Creating: ${TEMPDIR}" +Try { New-Item -Path $TEMPDIR -ItemType Directory -Force -ErrorAction Stop } +Catch { Write-Error $_.Exception.Message ; Return } + +# Write $CONFIG to config.xml +$CONFIGFILE = "${TEMPDIR}\config.xml" +Try { $CONFIG | WriteToFile_UTF8NoBOM -FilePath "${CONFIGFILE}" } +Catch { Write-Output "Cannot write configuration file! This script will exit." ; Write-Error $_.Exception.Message ; Return } + +# Set the name of ODT setup utility +$ODT = "${TEMPDIR}\setup.exe" + +# Download ODT +Write-Output "Downloading Office Deployment Tool" +Download-File -URL 'https://www.emberkom.com/odt/setup.exe' -File $ODT + +# Install Office +Write-Output "Installing Microsoft Office" +Try { Start-Process $ODT -ArgumentList "/configure ""${CONFIGFILE}""" -Wait } +Catch { Write-Error $_.Exception.Message } + +# Cleanup +Write-Output "Deleting temp directory and its contents" +Try { Remove-Item -Path $TEMPDIR -Recurse -Force -ErrorAction SilentlyContinue } +Catch { Write-Error $_.Exception.Message }