Skip to content

Instantly share code, notes, and snippets.

@steviecoaster
Created April 20, 2023 23:49
Show Gist options
  • Save steviecoaster/321628dfc6241d5984522633bbdaafb3 to your computer and use it in GitHub Desktop.
Save steviecoaster/321628dfc6241d5984522633bbdaafb3 to your computer and use it in GitHub Desktop.
Chocolatey Package - Office Install from ISO Example
#Setup variables
$ErrorActionPreference = 'Stop';
$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)"
$url = 'https://server:8443/repository/choco-install/Fabrikam_Office_Setup.iso'
$isoChecksum = 'c3a5c0d10747f80d0e60767b92a8ee4e8f0bdc5067b8747368fcf322926f887c'
$destination = Join-Path $toolsDir -ChildPath 'Fabrikam_Office_Setup.iso'
$officetempfolder = Join-Path $env:Temp 'chocolatey\Office365ProPlus'
#Download iso from URL
$isoArgs = @{
PackageName = $env:ChocolateyPackageName
url = $url
FileFullPath = $destination
checksum = $isoChecksum
checksumType = 'SHA256'
}
Get-ChocolateyWebFile @isoArgs
#Mount the iso
$mount = Mount-DiskImage -ImagePath $destination
$driveLetter = ($mount | Get-Volume).DriveLetter + ":\"
$fileLocation = Join-Path $driveLetter 'setup.exe'
$configurationFile = Join-Path $driveLetter 'configuration.xml'
$packageArgs = @{
packageName = $env:ChocolateyPackageName
fileType = 'EXE'
file = $fileLocation
softwareName = 'Microsoft Office 365 ProPlus*'
checksum = '942A5FA284DF6018AEC19110B0D9E68742194BFD44DD984B515ADF103D99775A'
checksumType = 'sha256'
silentArgs = "/configure $configurationFile"
validExitCodes= @(0)
useOriginalLocation = $true
}
Install-ChocolateyInstallPackage @packageArgs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment