forked from directorcia/Office365
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathc.ps1
124 lines (109 loc) · 4.44 KB
/
c.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
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
<# CIAOPS
Script provided as is. Use at own risk. No guarantees or warranty provided.
Description
Script designed to check and report the status of mailboxes in the tenant
Source - https://github.com/directorcia/Office365/blob/master/c.ps1
Notes -
Prerequisites - 0
More scripts available by joining http://www.ciaopspatron.com
#>
## Variables
$systemmessagecolor = "cyan"
$processmessagecolor = "green"
$errormessagecolor = "red"
$version = "2.00"
## 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
start-transcript "..\c.txt" | Out-Null ## Log file created in parent directory that is overwritten on each run
Clear-host
write-host -foregroundcolor $systemmessagecolor "Script started. Version = $version`n"
write-host -foregroundcolor cyan -backgroundcolor DarkBlue ">>>>>> Created by www.ciaops.com <<<<<<`n"
write-host "--- Script to connect to cloud services ---`n"
$scripts = @()
$scripts += [PSCustomObject]@{
Name = "o365-connect-mfa-tms.ps1";
Service = "Teams";
Module = "MicrosoftTeams"
}
$scripts += [PSCustomObject]@{
Name = "o365-connect-mfa-spo.ps1";
Service = "SharePoint";
Module = "Microsoft.Online.SharePoint.PowerShell"
}
$scripts += [PSCustomObject]@{
Name = "o365-connect-mfa-sac.ps1";
Service = "Security and Compliance";
Module = "MSOnline"
}
$scripts += [PSCustomObject]@{
Name = "o365-connect-mfa-s4b.ps1";
Service = "Skype for Business/CSTeams";
Module = "skypeonlineconnector"
}
$scripts += [PSCustomObject]@{
Name = "o365-connect-exov2.ps1";
Service = "Exchange Online";
Module ="ExchangeOnlineManagement"
}
$scripts += [PSCustomObject]@{
Name = "o365-connect-mfa-ctldply.ps1";
Service = "Central Add-in deployment";
Module = "";
}
$scripts += [PSCustomObject]@{
Name = "o365-connect-mfa-aadrm.ps1";
Service = "Azure AD Rights Management";
Module = "AADRM"
}
$scripts += [PSCustomObject]@{
Name = "o365-connect-mfa-aad.ps1";
Service = "Azure AD";
Module = "AzureAD"
}
$scripts += [PSCustomObject]@{
Name = "o365-connect-mfa.ps1";
Service = "MS Online";
Module = "MSOnline"
}
$scripts += [PSCustomObject]@{
Name = "Az-connect.ps1";
Service = "Azure";
Module = "Az.Accounts"
}
try {
$results = $scripts | select-object service | Sort-Object Service | Out-GridView -PassThru -title "Select services to connect to (Multiple selections permitted) "
}
catch {
write-host -ForegroundColor yellow -backgroundcolor $errormessagecolor "`n[001] - Error getting options`n"
Stop-Transcript | Out-Null ## Terminate transcription
exit 1 ## Terminate script
}
foreach ($result in $results) {
foreach ($script in $scripts) {
if ($result.service -eq $script.service) {
$run=".\"+$script.Name
if (-not [string]::isnullorempty($script.module)) { ## If a PowerShell module is required to be installed?
if (get-module -listavailable -name $script.module) { ## Has the Online PowerShell module been loaded?
write-host -ForegroundColor $processmessagecolor $script.module,"module found"
}
else {
write-host -ForegroundColor yellow -backgroundcolor $errormessagecolor "`n[002] - Online PowerShell module",$script.module,"not installed. Please install and re-run script`n"
Stop-Transcript | Out-Null ## Terminate transcription
exit 2 ## Terminate script
}
}
<# Test for script in current location #>
if (-not (test-path -path $run)) {
write-host -ForegroundColor yellow -backgroundcolor $errormessagecolor "`n[003] -",$script.name,"script not found in current directory - Please ensure exists first`n"
Stop-Transcript | Out-Null ## Terminate transcription
exit 3 ## Terminate script
}
else {
write-host -ForegroundColor $processmessagecolor $script.name,"script found in current directory`n"
}
&$run ## Run script
}
}
}
write-host -foregroundcolor $systemmessagecolor "`nScript finished`n"
Stop-Transcript | Out-Null