How I install Office 365 apps through NinjaOne. By default this will install in single-user mode. However, you can also choose to installed in Shared Computer Licensing mode by adding the SharedComputerLicensing parameter. You will need to modify the embedded xml file to suit your needs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
<# .NOTES =========================================================================== Created on: 07/03/2022 Created by: Jeff Irvine Organization: Techmological Filename: Install-Office365.ps1 =========================================================================== .DESCRIPTION Downloads and installs Office 365 apps. By default, this will install Office 365 apps in single-user mode. You can install in Shared Computer Licensing mode by adding the SharedComputerLicensing 1 parameter. Credit for a large portion of this script goes to: https://github.com/mallockey/Install-Office365Suite .EXAMPLE Install-Office365.ps1 -SharedComputerLicensing 1 #> param( [Parameter()][ValidateSet(0, 1)]$SharedComputerLicensing = '0' ) $OfficeInstallDownloadPath = "$PSScriptRoot\Office365Install" $CleanUpInstallFiles = $True if (-Not(Test-Path $OfficeInstallDownloadPath )) { New-Item -Path $OfficeInstallDownloadPath -ItemType Directory | Out-Null } $OfficeXML = [XML]@" <Configuration> <Add OfficeClientEdition="64" Channel="Monthly" OfficeMgmtCOM="FALSE"> <Product ID="O365ProPlusRetail"> <Language ID="en-us" /> <ExcludeApp ID="Groove" /> </Product> <Product ID="VisioProRetail"> <Language ID="en-us" /> <ExcludeApp ID="Groove" /> </Product> <Product ID="ProjectProRetail"> <Language ID="en-us" /> <ExcludeApp ID="Groove" /> </Product> </Add> <Updates Enabled="TRUE"/> <AppSettings> <Setup Name="Company" Value="COMPANYNAME" /> </AppSettings> <Property Name="SharedComputerLicensing" Value="$SharedComputerLicensing" /> <Display Level="None" AcceptEULA="TRUE" /> <Logging Level="Standard" Path="C:\Windows\Temp" /> </Configuration> "@ $OfficeXML.Save("$OfficeInstallDownloadPath\OfficeInstall.xml") function Get-ODTURL { [String]$MSWebPage = Invoke-RestMethod 'https://www.microsoft.com/en-us/download/confirmation.aspx?id=49117' $MSWebPage | ForEach-Object { if ($_ -match 'url=(https://.*officedeploymenttool.*\.exe)') { $matches[1] } } } $VerbosePreference = 'Continue' $ErrorActionPreference = 'Stop' $ConfigurationXMLFile = "$OfficeInstallDownloadPath\OfficeInstall.xml" $ODTInstallLink = Get-ODTURL #Download the Office Deployment Tool Write-Verbose 'Downloading the Office Deployment Tool...' try { Invoke-WebRequest -Uri $ODTInstallLink -OutFile "$OfficeInstallDownloadPath\ODTSetup.exe" } catch { Write-Warning 'There was an error downloading the Office Deployment Tool.' Write-Warning 'Please verify the below link is valid:' Write-Warning $ODTInstallLink exit 1 } #Run the Office Deployment Tool setup try { Write-Verbose 'Running the Office Deployment Tool...' Start-Process "$OfficeInstallDownloadPath\ODTSetup.exe" -ArgumentList "/quiet /extract:$OfficeInstallDownloadPath" -Wait } catch { Write-Warning 'Error running the Office Deployment Tool. The error is below:' Write-Warning $_ } #Run the O365 install try { Write-Verbose 'Downloading and installing Microsoft 365' $Silent = Start-Process "$OfficeInstallDownloadPath\Setup.exe" -ArgumentList "/configure $ConfigurationXMLFile" -Wait -PassThru } catch { Write-Warning 'Error running the Office install. The error is below:' Write-Warning $_ } #Check if Office 365 suite was installed correctly. $RegLocations = @('HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall', 'HKLM:\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall' ) $OfficeInstalled = $False foreach ($Key in (Get-ChildItem $RegLocations) ) { if ($Key.GetValue('DisplayName') -like '*Microsoft 365*') { $OfficeVersionInstalled = $Key.GetValue('DisplayName') $OfficeInstalled = $True } } if ($OfficeInstalled) { Write-Verbose "$($OfficeVersionInstalled) installed successfully!" } else { Write-Warning 'Microsoft 365 was not detected after the install ran' } if ($CleanUpInstallFiles) { Remove-Item -Path $OfficeInstallDownloadPath -Force -Recurse } # Create desktop shortcuts Write-Verbose "Creating desktop shortcuts..." Copy-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Excel.lnk" "C:\Users\Public\Desktop\" Copy-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Outlook.lnk" "C:\Users\Public\Desktop\" Copy-Item "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Word.lnk" "C:\Users\Public\Desktop\" |