01 November 2020

Install Office365 requirements with PowerShell - SkypeOnline - ExchangeOnline - AzureAD - SharepointOnline - Teams PowerShell modules

Updated - 01-11-2020

  • Replaced the SharePoint Online installer with the PowerShell Gallery module
  • Added Exchange Online V2 module
  • Updated SharePoint Online PowerShell module URL
  • Added Teams PowerShell module
  • Added AZ PowerShell module
  • Added Intune PowerShell module
  • Added Staff Hub PowerShell module

I came across a script by Chris Goosen to connect to all of the Office 365 services via PowerShell.
When I tried to run it errors were flying everywhere.
All of the requirements were missing on my system.

So that's what I came up with, a one stop way to get all of those requirements in one single go.
<#
.SYNOPSIS 
Install Office365 PowerShell Prerequisites
 
.DESCRIPTION  
Downloads and installs the AzureAD, Sharepoint Online, Skype Online for Windows PowerShell etc.

.Made by 
Edwin van Brenk

.Date
01-11-2020

.Source
https://vanbrenk.blogspot.com/2018/03/install-office365-requirements-with.html
#>            
                       
<#
Function InstallSharepointOnlinePowerShellModule() {

$SharepointOnlinePowerShellModuleSourceURL = "https://download.microsoft.com/download/0/2/E/02E7E5BA-2190-44A8-B407-BC73CA0D6B87/SharePointOnlineManagementShell_8525-1200_x64_en-us.msi"

$DestinationFolder = "C:\Temp"

     If (!(Test-Path $DestinationFolder))
     {
         New-Item $DestinationFolder -ItemType Directory -Force
     }

Write-Host "Downloading Sharepoint Online PowerShell Module from $SharepointOnlinePowerShellModuleSourceURL"

     try
     {
         Invoke-WebRequest -Uri $SharepointOnlinePowerShellModuleSourceURL -OutFile "$DestinationFolder\SharePointOnlineManagementShell_7414-1200_x64_en-us.msi" -ErrorAction STOP

$msifile = "$DestinationFolder\SharePointOnlineManagementShell_7414-1200_x64_en-us.msi"
$arguments = @(
          "/i"
          "`"$msiFile`""
          "/passive"
)

Write-Host "Attempting to install $msifile"

         $process = Start-Process -FilePath msiexec.exe -Wait -PassThru -ArgumentList $arguments
         if ($process.ExitCode -eq 0)
         {
             Write-Host "$msiFile has been successfully installed"
         }
         else
         {
             Write-Host "installer exit code  $($process.ExitCode) for file  $($msifile)"
         }

     }
     catch
     {
         Write-Host $_.Exception.Message
     }
 }

InstallSharepointOnlinePowerShellModule
#>            
            
# Download and Install Visual Studio C++ 2017                        
$VisualStudio2017x64URL = "https://download.visualstudio.microsoft.com/download/pr/11687625/2cd2dba5748dc95950a5c42c2d2d78e4/VC_redist.x64.exe"            
Write-Host "Downloading VisualStudio 2017 C++ from $VisualStudio2017x64"                         
            
$DestinationFolder = "C:\Temp"            
            
Invoke-WebRequest -Uri $VisualStudio2017x64URL -OutFile "$DestinationFolder\VC_redist.x64.exe" -ErrorAction STOP            
            
Write-Host "Attempting to install VisualStudio 2017 C++, a reboot is required!"            
            
Start-Process "$DestinationFolder\VC_redist.x64.exe" -ArgumentList "/passive /norestart" -Wait            
            
Write-Host "Attempting to install VisualStudio 2017 C++"            
            
# Download and Install Skype Online PowerShell module            
$SkypeOnlinePowerShellModuleSourceURL = "https://download.microsoft.com/download/2/0/5/2050B39B-4DA5-48E0-B768-583533B42C3B/SkypeOnlinePowerShell.Exe"            
            
$DestinationFolder = "C:\Temp"            
            
     If (!(Test-Path $DestinationFolder))            
     {            
         New-Item $DestinationFolder -ItemType Directory -Force            
     }            
            
Write-Host "Downloading Skype Online PowerShell Module from $SkypeOnlinePowerShellModuleSourceURL"            
            
Invoke-WebRequest -Uri $SkypeOnlinePowerShellModuleSourceURL -OutFile "$DestinationFolder\SkypeOnlinePowerShell.Exe" -ErrorAction STOP            
            
Start-Process "$DestinationFolder\SkypeOnlinePowerShell.Exe" -ArgumentList "/quiet" -Wait            
            
# Register PSGallery PSprovider and set as Trusted source            
Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/ -PublishLocation https://www.powershellgallery.com/api/v2/package/             
-ScriptSourceLocation https://www.powershellgallery.com/api/v2/items/psscript/ -ScriptPublishLocation https://www.powershellgallery.com/api/v2/package/ -InstallationPolicy             
Trusted -PackageManagementProvider NuGet -ErrorAction SilentlyContinue                        
Register-PSRepository -Default -ErrorAction SilentlyContinue            
Set-PSRepository -Name psgallery -InstallationPolicy trusted            
            
# Install modules from PSGallery            
Install-Module -Name AADRM -Force            
Install-Module -Name AzureADPreview -Force            
Install-Module -Name AzureAD -Force            
Install-Module -Name MSOnline -Force            
Install-Module -Name AZ -Force            
Install-Module -Name MicrosoftTeams -Force            
Install-Module -Name Microsoft.Graph.Intune -Force            
Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Force            
            
# Manually install Exchange Online with MFA authentication support from the Exchange Online ECP            
Write-Host "Login, go to Hybrid and download the Exchange Online Powershell module"            
Start-Process https://outlook.office365.com/ecp/

1 comment:

  1. Nice script thanks - the sharepoint location has changed and is now at https://download.microsoft.com/download/0/2/E/02E7E5BA-2190-44A8-B407-BC73CA0D6B87/SharePointOnlineManagementShell_8029-1200_x64_en-us.msi
    I also found that the register-psrepository command failed with "Register-PSRepository : Use 'Register-PSRepository -Default' to register the PSGallery repository.
    At line:1 char:1
    + Register-PSRepository -Name PSGallery -SourceLocation https://www.pow ..."

    However the subsquent lines continue to do the installation with no problems.
    You do however have to download the exchange online module with internet explorer. Attempting to use chrome fails due to the clickonce setup.

    ReplyDelete