forked from directorcia/Office365
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patho365-setup.ps1
90 lines (79 loc) · 5.16 KB
/
o365-setup.ps1
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
<# CIAOPS
Script provided as is. Use at own risk. No guarantees or warranty provided.
## Description - Install the relevant Microsoft Online PowerShell modules
Source - https://github.com/directorcia/Office365/blob/master/o365-setup.ps1
Prerequisites = 1
1. Run PowerShell environment as an administrator
More scripts available by joining http://www.ciaopspatron.com
#>
## Variables
$systemmessagecolor = "cyan"
$processmessagecolor = "green"
$errormessagecolor = "red"
$warningmessagecolor = "yellow"
## If you have running scripts that don't have a certificate, run this command once to disable that level of security
## set-executionpolicy -executionpolicy bypass -scope currentuser -force
Clear-Host
if ((get-host).name -match "ISE") {Write-host "`n`n`n`n`n`n`n`n`n"} # move text down for ISE where dialog will hide
write-host -foregroundcolor $systemmessagecolor "Start Script`n"
$currentPrincipal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent())
If ($currentPrincipal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) {
write-host -ForegroundColor $processmessagecolor "Checking PowerShell Execution Policy"
$result = Get-ExecutionPolicy -Scope CurrentUser
if ($result -ne "Bypass") {
write-host -ForegroundColor $warningmessagecolor " - [Warning] - Currentuser not set to bypass to allow scripts to run"
write-host -ForegroundColor $processmessagecolor " - Setting Currentuser to bypass to allow scripts to run"
set-executionpolicy -executionpolicy bypass -scope currentuser -force
}
else {
write-host -ForegroundColor $processmessagecolor " - Currentuser is set to bypass to allow scripts to run"
}
write-host -foregroundcolor $processmessagecolor "`n(1 of 12) Install NuGet provider"
Install-PackageProvider -Name NuGet -Force -confirm:$false | Out-Null
write-host -foregroundcolor $processmessagecolor "(2 of 12) Install Azure AD module"
Install-Module -Name AzureAD -force -confirm:$false
write-host -foregroundcolor $processmessagecolor "(3 of 12) Install Azure Information Protection module"
## Install-Module -Name AADRM -force ## Support for the AADRM module ends July 15, 2020
$aadrmcheck = get-module -listavailable -name aadrm
if ($aadrmcheck) {
write-host -foregroundcolor $warningmessagecolor " - [Warning] Older module Azure AD Rights management module (AADRM) is still installed"
write-host -foregroundcolor $processmessagecolor " - Uninstalling AADRM module as support ended July 15, 2020 "
uninstall-module aadrm -force -confirm:$false
write-host -foregroundcolor $processmessagecolor " - New Azure Information Protection module will now be installed"
}
Install-module -name aipservice -Force -confirm:$false
write-host -foregroundcolor $processmessagecolor "(4 of 12) Install Teams Module"
Install-Module -Name MicrosoftTeams -Force -confirm:$false
write-host -foregroundcolor $processmessagecolor "(5 of 12) Install SharePoint Online module"
Install-Module -Name Microsoft.Online.SharePoint.PowerShell -force -confirm:$false
write-host -foregroundcolor $processmessagecolor "(6 of 12) Install Microsoft Online module"
Install-Module -Name MSOnline -force -confirm:$false
write-host -foregroundcolor $processmessagecolor "(7 of 12) Install Exchange Online module"
Install-Module PowershellGet -Force -confirm:$false
Install-Module -Name ExchangeOnlineManagement -force -confirm:$false
write-host -foregroundcolor $processmessagecolor "(8 of 12) Install Azure module"
## Old Azure module
## Install-Module -name AzureRM -Force
## New Az module
Install-Module -name Az -force -confirm:$false
write-host -foregroundcolor $processmessagecolor "(9 of 12) Install SharePoint PnP module"
$pnpcheck = get-module -listavailable -name SharePointPnPPowerShellOnline
if ($pnpcheck) {
write-host -foregroundcolor $warningmessagecolor " - [Warning] Older SharePoint PnP module is still installed"
write-host -foregroundcolor $processmessagecolor " - Uninstalling older SharePoint PnP module"
uninstall-module SharePointPnPPowerShellOnline -allversions -force -confirm:$false
write-host -foregroundcolor $processmessagecolor " - New SharePoint PnP module will now be installed"
}
Install-Module PnP.PowerShell -Force -confirm:$false
write-host -foregroundcolor $processmessagecolor "(10 of 12) Install Microsoft Graph Module"
Install-Module -Name Microsoft.Graph -force -confirm:$false
write-host -foregroundcolor $processmessagecolor "(11 of 12) Install Windows Autopilot Module"
## will also update dependent AzureAD and Microsoft.Graph.Intune modules
Install-Module -Name WindowsAutoPilotIntune -force -confirm:$false
write-host -foregroundcolor $processmessagecolor "(12 of 12) Install Centralised Add-in Deployment"
Install-module -name O365CentralizedAddInDeployment -force -confirm:$false
}
else {
write-host -foregroundcolor $errormessagecolor "*** ERROR *** - Please re-run PowerShell environment as Administrator`n"
}
write-host -foregroundcolor $systemmessagecolor "Script completed`n"