Install all the required Office 365 and Azure PowerShell modules at once.

Updated - 04-03-2019

This script will install all the required modules for Sharepoint Online, AzureAD, Skype Online and Teams.
Exchange Online will not be installed automatically, but you will be taken to the ExchangeOnline portal where you can download the required PowerShell module.

The required Visual Studio C++ 2017 will also be downloaded and installed.
This is required for the Skype Online PowerShell module.

Check the original post at:



Install Office365 PowerShell Prerequisites 
Downloads and installs the AzureAD, Sharepoint Online, Skype Online for Windows PowerShell 
.Made by  
Edwin van brenk 
Function InstallSharepointOnlinePowerShellModule() { 
$SharepointOnlinePowerShellModuleSourceURL = "" 
$DestinationFolder = "C:\Temp" 
     If (!(Test-Path $DestinationFolder)) 
         New-Item $DestinationFolder -ItemType Directory -Force 
Write-Host "Downloading Sharepoint Online PowerShell Module from $SharepointOnlinePowerShellModuleSourceURL" 
         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 = @( 
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" 
             Write-Host "installer exit code  $($process.ExitCode) for file  $($msifile)" 
         Write-Host $_.Exception.Message 
# Download and Install Visual Studio C++ 2017             
$VisualStudio2017x64URL = ""             
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 = "" 
$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 -PublishLocation  
-ScriptSourceLocation -ScriptPublishLocation -InstallationPolicy  
Trusted -PackageManagementProvider NuGet -ErrorAction SilentlyContinue             
Set-PSRepository -Name psgallery -InstallationPolicy trusted 
# Install modules from PSGallery 
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 
# 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"