-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathInstallM365ModulesPowerShell.ps1
More file actions
436 lines (387 loc) · 21 KB
/
InstallM365ModulesPowerShell.ps1
File metadata and controls
436 lines (387 loc) · 21 KB
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
#=================================================================
#Name: Windows PowerShell Modules Installer.
#Description: Install all PowerShell Modules for Microsoft 365.
#Version: 1.2
#Date : 08/8/2023
#Website: https://bonguides.com
#Script by: Leo Nguyen
#For detailed script execution: https://bonguides.com
#=================================================================
#Required running with elevated right.
if (-not([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator")) {
Write-Warning "You need to have Administrator rights to run this script!`nPlease re-run this script as an Administrator in an elevated powershell prompt!"
break
}
#Create GUI PowerShell
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Drawing")
[void] [System.Reflection.Assembly]::LoadWithPartialName("PresentationFramework")
[void] [Reflection.Assembly]::LoadWithPartialName("PresentationCore")
$Form = New-Object System.Windows.Forms.Form
$Form.Size = New-Object System.Drawing.Size(400,400)
$Form.StartPosition = "CenterScreen" #loads the window in the center of the screen
$Form.FormBorderStyle = [System.Windows.Forms.FormBorderStyle]::FixedToolWindow #modifies the window border
$Form.Text = "M365 PoweShell Modules Installation - www.bonguides.com" #window description
$Form.ShowInTaskbar = $True
$Form.KeyPreview = $True
$Form.AutoSize = $True
$Form.FormBorderStyle = 'Fixed3D'
$Form.MaximizeBox = $False
$Form.MinimizeBox = $False
$Form.ControlBox = $True
$Form.Icon = $Icon
$install = {
#Configure Execution Policy
if ((Get-ExecutionPolicy) -notmatch "RemoteSigned") {
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force
}
#Update the NuGet Provider if needed.
$nuGetPath = "C:\Program Files\PackageManagement\ProviderAssemblies\nuget\*\Microsoft.PackageManagement.NuGetProvider.dll"
$testPath = Test-Path -Path $nuGetPath
if ($testPath -match 'false') {
Write-Host "`nInstalling NuGet Provider..."
Install-PackageProvider -Name NuGet -Force | Out-Null
}
#We're installing from the PowerShell Gallery so make sure that it's trusted
if (((Get-PSRepository -Name PSGallery).InstallationPolicy) -match "Untrusted") {
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
}
ForEach ($Module in $O365Modules) {
$PCModule = Get-InstalledModule -Name $Module -ErrorAction SilentlyContinue
Write-Host "Checking and updating module" $Module -ForegroundColor Yellow
$CurrentModule = Find-Module -Name $Module
If ($CurrentModule) {
$CurrentVersion = $CurrentModule.Version
If ($CurrentVersion -isnot [string]) {
$CurrentVersion = $CurrentVersion.Major.toString() + "." + $CurrentVersion.Minor.toString() + "." + $CurrentVersion.Build.toString()
}
[datetime]$CurrentModuleDate = $CurrentModule.PublishedDate
Write-Host ("Current version of the {0} module in the PowerShell Gallery is {1}" -f $Module, $CurrentVersion) -ForegroundColor Yellow
}
If (!($PCModule)){
#No version of the module found. It's in our list, so we install it.
Write-Host ("No module found on this PC for {0}" -f $Module) -ForegroundColor Yellow
Write-Host ("Installing module {0}..." -f $Module) -foregroundcolor Green
Install-Module $Module -Scope AllUsers -Confirm:$False -AllowClobber -Force
}
If ($PCModule){
$PCVersion = $PCModule.Version
If ($PCVersion -isnot [string]){
$PCVersion = $PCVersion.Major.toString() + "." + $PCVersion.Minor.toString() + "." + $PCVersion.Build.toString()
}
[datetime]$PCModuleDate = $PCModule.PublishedDate
}
If ($PCModuleDate -eq $CurrentModuleDate){
Write-Host ("Latest version of {0} is installed on this PC - no need to update" -f $Module) -ForegroundColor Green
}
#Check and remove older versions of the modules from the PC
Write-Host "Beginning clean-up phase..." -ForegroundColor Yellow
Write-Host "Checking for older versions of" $Module -ForegroundColor Yellow
[array]$AllVersions = Get-InstalledModule -Name $Module -AllVersions -ErrorAction SilentlyContinue
If ($AllVersions){
$AllVersions = $AllVersions | Sort-Object PublishedDate -Descending
$MostRecentVersion = $AllVersions[0].Version
If ($MostRecentVersion -isnot [string]) { # Handle PowerShell 5 - PowerShell 7 returns a string
$MostRecentVersion = $MostRecentVersion.Major.toString() + "." + $MostRecentVersion.Minor.toString() + "." + $MostRecentVersion.Build.toString()
}
[datetime]$MostRecentVersionDate = $AllVersions[0].PublishedDate
$PublishedDate = (Get-Date($MostRecentVersionDate) -format g)
Write-Host ("Most recent version of {0} is {1} published on {2}" -f $Module, $MostRecentVersion, $PublishedDate) -ForegroundColor Green
If ($AllVersions.Count -gt 1 ) { # More than a single version installed
ForEach ($Version in $AllVersions){ #Check each version and remove old versions
[datetime]$VersionDate = $Version.PublishedDate
If ($VersionDate -lt $MostRecentVersionDate){ # Old version - remove
Write-Host ("Uninstalling version {0} of module {1}" -f $Version.Version, $Module) -foregroundcolor Red
Uninstall-Module -Name $Module -RequiredVersion $Version.Version -Force
} #End if version check
} # End ForEach versions
} else {
Write-Host ("No earlier versions of {0} module to remove" -f $Module)
} # End check for more than one version
} #End If
Write-Host ("Done.") -ForegroundColor Green
}
}
$update = {
if ((Get-ExecutionPolicy) -notmatch "RemoteSigned") {
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force
}
ForEach ($Module in $O365Modules) {
$PCModule = Get-InstalledModule -Name $Module -ErrorAction SilentlyContinue
Write-Host "Checking and updating module" $Module -ForegroundColor Yellow
$CurrentModule = Find-Module -Name $Module
If ($CurrentModule) {
$CurrentVersion = $CurrentModule.Version
If ($CurrentVersion -isnot [string]) {
$CurrentVersion = $CurrentVersion.Major.toString() + "." + $CurrentVersion.Minor.toString() + "." + $CurrentVersion.Build.toString()
}
[datetime]$CurrentModuleDate = $CurrentModule.PublishedDate
Write-Host ("Current version of the {0} module in the PowerShell Gallery is {1}" -f $Module, $CurrentVersion) -ForegroundColor Yellow
}
If (!($PCModule)) {
#No version of the module found. It's in our list, so we install it.
Write-Host ("No module found on this PC for {0}" -f $Module) -ForegroundColor Yellow
Write-Host ("Installing module {0}..." -f $Module) -foregroundcolor Yellow
Install-Module $Module -Scope AllUsers -Confirm:$False -AllowClobber -Force
}
If ($PCModule) {
$PCVersion = $PCModule.Version
If ($PCVersion -isnot [string]) {
$PCVersion = $PCVersion.Major.toString() + "." + $PCVersion.Minor.toString() + "." + $PCVersion.Build.toString()
}
[datetime]$PCModuleDate = $PCModule.PublishedDate
}
If ($PCModuleDate -eq $CurrentModuleDate) {
Write-Host ("Latest version of {0} is installed on this PC - no need to update" -f $Module) -ForegroundColor Yellow
} Else {
Write-Host ("Updating {0} module to version {1}" -f $Module, $CurrentVersion) -foregroundcolor Green
Remove-Module $Module -ErrorAction SilentlyContinue
Update-Module $Module -Force -Confirm:$False -Scope AllUsers
} # End if
#Check and remove older versions of the modules from the PC
Write-Host "Beginning clean-up phase..." -ForegroundColor Green
Write-Host "Checking for older versions of" $Module -ForegroundColor Green
[array]$AllVersions = Get-InstalledModule -Name $Module -AllVersions -ErrorAction SilentlyContinue
If ($AllVersions) {
$AllVersions = $AllVersions | Sort-Object PublishedDate -Descending
$MostRecentVersion = $AllVersions[0].Version
If ($MostRecentVersion -isnot [string]) { # Handle PowerShell 5 - PowerShell 7 returns a string
$MostRecentVersion = $MostRecentVersion.Major.toString() + "." + $MostRecentVersion.Minor.toString() + "." + $MostRecentVersion.Build.toString()
}
[datetime]$MostRecentVersionDate = $AllVersions[0].PublishedDate
$PublishedDate = (Get-Date($MostRecentVersionDate) -format g)
Write-Host ("Most recent version of {0} is {1} published on {2}" -f $Module, $MostRecentVersion, $PublishedDate)
If ($AllVersions.Count -gt 1 ) { # More than a single version installed
ForEach ($Version in $AllVersions) { #Check each version and remove old versions
[datetime]$VersionDate = $Version.PublishedDate
If ($VersionDate -lt $MostRecentVersionDate) { # Old version - remove
Write-Host ("Uninstalling version {0} of module {1}" -f $Version.Version, $Module) -foregroundcolor Red
Uninstall-Module -Name $Module -RequiredVersion $Version.Version -Force
} #End if version check
} # End ForEach versions
} Else {
Write-Host ("No earlier versions of {0} module to remove" -f $Module)
} # End check for more than one version
} #End If
Write-Host ("Done.") -ForegroundColor Green
}
}
$uninstall = {
if ((Get-ExecutionPolicy) -notmatch "RemoteSigned") {
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine -Force
}
ForEach ($Module in $O365Modules) {
Write-Host ("Uninstalling $Module") -foregroundcolor Yellow
Uninstall-Module -Name $Module -AllVersions -Force -ErrorAction SilentlyContinue
Write-Host ("Done.") -ForegroundColor Green
}
}
#Start functions
function m365ModulesInstall {
try {
if ($msonlinecb.Checked -eq $true) {$O365Modules = @("MSOnline"); Invoke-Command $install}
if ($azureadcb.Checked -eq $true) {$O365Modules = @("AzureAD"); Invoke-Command $install}
if ($exchangeonlinecb.Checked -eq $true) {$O365Modules = @("ExchangeOnlineManagement"); Invoke-Command $install}
if ($sharepointcb.Checked -eq $true) {$O365Modules = @("Microsoft.Online.Sharepoint.PowerShell"); Invoke-Command $install}
if ($msteamscb.Checked -eq $true) {$O365Modules = @("MicrosoftTeams"); Invoke-Command $install}
if ($graphapicb.Checked -eq $true) {$O365Modules = @("Microsoft.Graph", "Microsoft.Graph.Beta"); Invoke-Command $install}
if ($azureazcb.Checked -eq $true) {$O365Modules = @("Az"); Invoke-Command $install}
if ($mdecb.Checked -eq $true) {$O365Modules = @("PSMDATP"); Invoke-Command $install}
if ($intunecb.Checked -eq $true) {$O365Modules = @("Microsoft.Graph.Intune"); Invoke-Command $install}
if ($uprintcb.Checked -eq $true) {$O365Modules = @("UniversalPrintManagement"); Invoke-Command $install}
if ($azurermcb.Checked -eq $true) {$O365Modules = @("AzureRM"); Invoke-Command $install}
if ($powerappscb.Checked -eq $true) {$O365Modules = @("Microsoft.PowerApps.Administration.PowerShell", "Microsoft.PowerApps.PowerShell"); Invoke-Command $install}
if ($allcb.Checked -eq $true) {$O365Modules = @(
"MSOnline",
"AzureAD",
"ExchangeOnlineManagement",
"Microsoft.Online.Sharepoint.PowerShell",
"MicrosoftTeams",
"Microsoft.Graph",
"Microsoft.Graph.Beta",
"Az", "PSMDATP",
"Microsoft.Graph.Intune",
"UniversalPrintManagement",
"AzureRM",
"Microsoft.PowerApps.Administration.PowerShell",
"Microsoft.PowerApps.PowerShell" );
Invoke-Command $install}
}
catch {
}
}
function m365ModulesUpdate {
try {
if ($msonlinecb.Checked -eq $true) {$O365Modules = @("MSOnline"); Invoke-Command $update}
if ($azureadcb.Checked -eq $true) {$O365Modules = @("AzureAD"); Invoke-Command $update}
if ($exchangeonlinecb.Checked -eq $true) {$O365Modules = @("ExchangeOnlineManagement"); Invoke-Command $update}
if ($sharepointcb.Checked -eq $true) {$O365Modules = @("Microsoft.Online.Sharepoint.PowerShell"); Invoke-Command $update}
if ($msteamscb.Checked -eq $true) {$O365Modules = @("MicrosoftTeams"); Invoke-Command $update}
if ($graphapicb.Checked -eq $true) {$O365Modules = @("Microsoft.Graph", "Microsoft.Graph.Beta"); Invoke-Command $update}
if ($azureazcb.Checked -eq $true) {$O365Modules = @("Az"); Invoke-Command $update}
if ($mdecb.Checked -eq $true) {$O365Modules = @("PSMDATP"); Invoke-Command $update}
if ($intunecb.Checked -eq $true) {$O365Modules = @("Microsoft.Graph.Intune"); Invoke-Command $update}
if ($uprintcb.Checked -eq $true) {$O365Modules = @("UniversalPrintManagement"); Invoke-Command $update}
if ($azurermcb.Checked -eq $true) {$O365Modules = @("AzureRM"); Invoke-Command $update}
if ($powerappscb.Checked -eq $true) {$O365Modules = @("Microsoft.PowerApps.Administration.PowerShell", "Microsoft.PowerApps.PowerShell"); Invoke-Command $update}
if ($allcb.Checked -eq $true) {$O365Modules = @(
"MSOnline",
"AzureAD",
"ExchangeOnlineManagement",
"Microsoft.Online.Sharepoint.PowerShell",
"MicrosoftTeams",
"Microsoft.Graph",
"Microsoft.Graph.Beta",
"Az", "PSMDATP",
"Microsoft.Graph.Intune",
"UniversalPrintManagement",
"AzureRM",
"Microsoft.PowerApps.Administration.PowerShell",
"Microsoft.PowerApps.PowerShell" );
Invoke-Command $update}
}
catch {
}
}
function m365ModulesUninstall {
try {
if ($msonlinecb.Checked -eq $true) {$O365Modules = @("MSOnline"); Invoke-Command $Uninstall}
if ($azureadcb.Checked -eq $true) {$O365Modules = @("AzureAD"); Invoke-Command $Uninstall}
if ($exchangeonlinecb.Checked -eq $true) {$O365Modules = @("ExchangeOnlineManagement"); Invoke-Command $Uninstall}
if ($sharepointcb.Checked -eq $true) {$O365Modules = @("Microsoft.Online.Sharepoint.PowerShell"); Invoke-Command $Uninstall}
if ($msteamscb.Checked -eq $true) {$O365Modules = @("MicrosoftTeams"); Invoke-Command $Uninstall}
if ($graphapicb.Checked -eq $true) {$O365Modules = @("Microsoft.Graph", "Microsoft.Graph.Beta"); Invoke-Command $Uninstall}
if ($azureazcb.Checked -eq $true) {$O365Modules = @("Az"); Invoke-Command $Uninstall}
if ($mdecb.Checked -eq $true) {$O365Modules = @("PSMDATP"); Invoke-Command $Uninstall}
if ($intunecb.Checked -eq $true) {$O365Modules = @("Microsoft.Graph.Intune"); Invoke-Command $Uninstall}
if ($uprintcb.Checked -eq $true) {$O365Modules = @("UniversalPrintManagement"); Invoke-Command $Uninstall}
if ($azurermcb.Checked -eq $true) {$O365Modules = @("AzureRM"); Invoke-Command $Uninstall}
if ($powerappscb.Checked -eq $true) {$O365Modules = @("Microsoft.PowerApps.Administration.PowerShell", "Microsoft.PowerApps.PowerShell"); Invoke-Command $Uninstall}
if ($allcb.Checked -eq $true) {$O365Modules = @(
"MSOnline",
"AzureAD",
"ExchangeOnlineManagement",
"Microsoft.Online.Sharepoint.PowerShell",
"MicrosoftTeams",
"Microsoft.Graph",
"Microsoft.Graph.Beta",
"Az", "PSMDATP",
"Microsoft.Graph.Intune",
"UniversalPrintManagement",
"AzureRM",
"Microsoft.PowerApps.Administration.PowerShell",
"Microsoft.PowerApps.PowerShell" );
Invoke-Command $Uninstall}
}
catch {
}
}
#End functions
#Start group boxes
$installModule = New-Object System.Windows.Forms.GroupBox
$installModule.Location = New-Object System.Drawing.Size(10,10)
$installModule.size = New-Object System.Drawing.Size(180,270)
$installModule.text = "Select a module:"
$Form.Controls.Add($installModule)
############################################## end group boxes
############################################## Start Arch checkboxes
$msonlinecb = New-Object System.Windows.Forms.RadioButton
$msonlinecb.Location = New-Object System.Drawing.Size(10,20)
$msonlinecb.Size = New-Object System.Drawing.Size(120,20)
$msonlinecb.Checked = $false
$msonlinecb.Text = "MSOnline"
$installModule.Controls.Add($msonlinecb)
$azureadcb = New-Object System.Windows.Forms.RadioButton
$azureadcb.Location = New-Object System.Drawing.Size(10,40)
$azureadcb.Size = New-Object System.Drawing.Size(120,20)
$azureadcb.Checked = $false
$azureadcb.Text = "AzureAD"
$installModule.Controls.Add($azureadcb)
$exchangeonlinecb = New-Object System.Windows.Forms.RadioButton
$exchangeonlinecb.Location = New-Object System.Drawing.Size(10,60)
$exchangeonlinecb.Size = New-Object System.Drawing.Size(120,20)
$exchangeonlinecb.AutoSize = $True
$exchangeonlinecb.Text = "Exchange Online"
$installModule.Controls.Add($exchangeonlinecb)
$msteamscb = New-Object System.Windows.Forms.RadioButton
$msteamscb.Location = New-Object System.Drawing.Size(10,80)
$msteamscb.Size = New-Object System.Drawing.Size(120,20)
$msteamscb.Checked = $false
$msteamscb.Text = "Teams"
$installModule.Controls.Add($msteamscb)
$sharepointcb = New-Object System.Windows.Forms.RadioButton
$sharepointcb.Location = New-Object System.Drawing.Size(10,100)
$sharepointcb.Size = New-Object System.Drawing.Size(120,20)
$sharepointcb.Checked = $false
$sharepointcb.Text = "Sharepoint"
$installModule.Controls.Add($sharepointcb)
$azureazcb = New-Object System.Windows.Forms.RadioButton
$azureazcb.Location = New-Object System.Drawing.Size(10,120)
$azureazcb.Size = New-Object System.Drawing.Size(120,20)
$azureazcb.Text = "Azure Az"
$installModule.Controls.Add($azureazcb)
$azurermcb = New-Object System.Windows.Forms.RadioButton
$azurermcb.Location = New-Object System.Drawing.Size(10,120)
$azurermcb.Size = New-Object System.Drawing.Size(120,20)
$azurermcb.Text = "Azure RM"
$installModule.Controls.Add($azurermcb)
$mdecb = New-Object System.Windows.Forms.RadioButton
$mdecb.Location = New-Object System.Drawing.Size(10,140)
$mdecb.Size = New-Object System.Drawing.Size(120,20)
$mdecb.AutoSize = $True
$mdecb.Text = "Defender Endpoint"
$installModule.Controls.Add($mdecb)
$intunecb = New-Object System.Windows.Forms.RadioButton
$intunecb.Location = New-Object System.Drawing.Size(10,160)
$intunecb.Size = New-Object System.Drawing.Size(120,20)
$intunecb.Text = "Intune"
$installModule.Controls.Add($intunecb)
$uprintcb = New-Object System.Windows.Forms.RadioButton
$uprintcb.Location = New-Object System.Drawing.Size(10,180)
$uprintcb.Size = New-Object System.Drawing.Size(120,20)
$uprintcb.Text = "Universal Print"
$installModule.Controls.Add($uprintcb)
$powerappscb = New-Object System.Windows.Forms.RadioButton
$powerappscb.Location = New-Object System.Drawing.Size(10,200)
$powerappscb.Size = New-Object System.Drawing.Size(120,20)
$powerappscb.Text = "PowerApps"
$installModule.Controls.Add($powerappscb)
$graphapicb = New-Object System.Windows.Forms.RadioButton
$graphapicb.Location = New-Object System.Drawing.Size(10,220)
$graphapicb.Size = New-Object System.Drawing.Size(120,20)
$graphapicb.Text = "Microsoft Grap PowerShell"
$installModule.Controls.Add($graphapicb)
$allcb = New-Object System.Windows.Forms.RadioButton
$allcb.Location = New-Object System.Drawing.Size(10,240)
$allcb.Size = New-Object System.Drawing.Size(120,20)
$allcb.Text = "All Services"
$installModule.Controls.Add($allcb)
############################################## End Arch checkboxes
############################################## Start buttons
$submitButton = New-Object System.Windows.Forms.Button
$submitButton.Cursor = [System.Windows.Forms.Cursors]::Hand
$submitButton.BackColor = [System.Drawing.Color]::LightGreen
$submitButton.Location = New-Object System.Drawing.Size(10,300)
$submitButton.Size = New-Object System.Drawing.Size(110,40)
$submitButton.Text = "Install"
$submitButton.Add_Click({m365ModulesInstall})
$Form.Controls.Add($submitButton)
$updateButton = New-Object System.Windows.Forms.Button
$updateButton.Cursor = [System.Windows.Forms.Cursors]::Hand
$updateButton.BackColor = [System.Drawing.Color]::Blue
$updateButton.Location = New-Object System.Drawing.Size(130,300)
$updateButton.Size = New-Object System.Drawing.Size(110,40)
$updateButton.Text = "Update"
$updateButton.Add_Click({m365ModulesUpdate})
$Form.Controls.Add($updateButton)
$uninstallButton = New-Object System.Windows.Forms.Button
$uninstallButton.Cursor = [System.Windows.Forms.Cursors]::Hand
$uninstallButton.BackColor = [System.Drawing.Color]::Red
$uninstallButton.Location = New-Object System.Drawing.Size(250,300)
$uninstallButton.Size = New-Object System.Drawing.Size(110,40)
$uninstallButton.Text = "Uninstall"
$uninstallButton.Add_Click({m365ModulesUninstall})
$Form.Controls.Add($uninstallButton)
############################################## end buttons
$Form.Add_Shown({$Form.Activate()})
[void] $Form.ShowDialog()