-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathLabTech 10.5 Discovery Wizard Installer.ps1
722 lines (566 loc) · 28.5 KB
/
LabTech 10.5 Discovery Wizard Installer.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
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
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2015 v4.2.89
Created on: 9/2/2015 3:33 PM
Revision: 2.0.0
Created by: Marcus Bastian and Phillip Marshall
Organization: ConnectWise
Filename: Perform Installation of LabTech Server.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
<#######################################################################################>
#Function Declarations
Function StartProcWithWait
{
$InstallApplication = $args[0];
$InstallProc = New-Object System.Diagnostics.Process;
$InstallProc.StartInfo = $InstallApplication;
$InstallProc.Start();
$InstallProc.WaitForExit();
}
Function Zip-Actions
{
<#
.SYNOPSIS
A function to zip or unzip files.
.DESCRIPTION
This function has 3 possible uses.
1) Zip a folder or files and save the zip to specified location.
2) Unzip a zip file to a specified folder.
3) Unzip a zip file and delete the original zip when complete.
.PARAMETER ZipPath
The full path of the file to unzip or the full path of the zip file to be created.
.PARAMETER FolderPath
The path to the files to zip or the path to the directory to unzip the files to.
.PARAMETER Unzip
If $true the function will perform an unzip instead of a zip
.PARAMETER DeleteZip
If set to $True the zip file will be removed at then end of the unzip operation.
.EXAMPLE
PS C:\> Zip-Actions -ZipPath 'C:\Windows\Temp\ziptest.zip' -FolderPath
PS C:\> Zip-Actions -ZipPath 'C:\Windows\Temp\ziptest.zip' -FolderPath 'C:\Windows\Temp\ZipTest' -Unzip $true
PS C:\> Zip-Actions -ZipPath 'C:\Windows\Temp\ziptest.zip' -FolderPath 'C:\Windows\Temp\ZipTest' -Unzip $true -DeleteZip $True
.NOTES
Additional information about the function.
#>
[CmdletBinding(DefaultParameterSetName = 'Zip')]
param
(
[Parameter(ParameterSetName = 'Unzip')]
[Parameter(ParameterSetName = 'Zip',
Mandatory = $true,
Position = 0)]
[ValidateNotNull()]
[string]$ZipPath,
[Parameter(ParameterSetName = 'Unzip')]
[Parameter(ParameterSetName = 'Zip',
Mandatory = $true,
Position = 1)]
[ValidateNotNull()]
[string]$FolderPath,
[Parameter(ParameterSetName = 'Unzip',
Mandatory = $false,
Position = 2)]
[ValidateNotNull()]
[bool]$Unzip,
[Parameter(ParameterSetName = 'Unzip',
Mandatory = $false,
Position = 3)]
[ValidateNotNull()]
[bool]$DeleteZip
)
Write-Output "Entering Zip-Actions Function." -Severity 1
switch ($PsCmdlet.ParameterSetName)
{
'Zip' {
If ([int]$psversiontable.psversion.Major -lt 3)
{
New-Item $ZipPath -ItemType file
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($ZipPath)
$files = Get-ChildItem -Path $FolderPath -Recurse
foreach ($file in $files)
{
$zipPackage.CopyHere($file.FullName)
Start-sleep -milliseconds 500
}
Write-Output "Exiting Zip-Actions Function." -Severity 1
break
}
Else
{
Add-Type -assembly "system.io.compression.filesystem"
$Compression = [System.IO.Compression.CompressionLevel]::Optimal
[io.compression.zipfile]::CreateFromDirectory($FolderPath, $ZipPath, $Compression, $True)
Write-Output "Exiting Zip-Actions Function." -Severity 1
break
}
}
'Unzip' {
<#
Add-Type -assembly "system.io.compression.filesystem"
$Compression = [System.IO.Compression.CompressionLevel]::Optimal
[io.compression.zipfile]::ExtractToDirectory($ZipPath, $FolderPath)
If ($DeleteZip) { Remove-item $ZipPath }
Write-Output "Exiting Zip-Actions Function." -Severity 1
break
#>
$shellApplication = new-object -com shell.application
$zipPackage = $shellApplication.NameSpace($ZipPath)
$destinationFolder = $shellApplication.NameSpace($FolderPath)
$destinationFolder.CopyHere($zipPackage.Items(), 20)
}
}
}
Function Process-Features
{
param
(
[parameter(Mandatory = $true)]
[String]$OS
)
Switch ($OS)
{
2008R2
{
foreach($Feature in $2008R2Features)
{
Write-Output "Starting install of $($Feature)"
$Install = Add-WindowsFeature $Feature
If($install.success -ne $True)
{
$RolesThatFailedToInstall += $Feature
Write-output "ERROR: Feature $($Feature) failed to install."
}
Else
{
Write-output "SUCCESS: Feature $($Feature) Installed."
}
}
}
2012R2
{
foreach($Feature in $2012R2features)
{
Write-Output "Starting install of $($Feature)"
$Install = Add-WindowsFeature $Feature
If($install.success -ne $True)
{
$RolesThatFailedToInstall += $Feature
Write-output "ERROR: Feature $($Feature) failed to install."
}
Else
{
Write-output "SUCCESS: Feature $($Feature) Installed."
}
}
}
2012Standard
{
foreach($Feature in $2012features)
{
Write-Output "Starting install of $($Feature)"
$Install = Add-WindowsFeature $Feature
If($install.success -ne $True)
{
$RolesThatFailedToInstall += $Feature
Write-output "ERROR: Feature $($Feature) failed to install."
}
Else
{
Write-output "SUCCESS: Feature $($Feature) Installed."
}
}
}
}
}
Function Write-Log
{
Param
(
[Parameter(Mandatory = $True, Position = 0)]
[String]$Message,
[Parameter(Mandatory = $False, Position = 1)]
[INT]$Severity
)
$Note = "[NOTE]"
$Warning = "[WARNING]"
$Problem = "[ERROR]"
[string]$Date = get-date
switch ($Severity)
{
1 { add-content -path $LogFilePath -value ($Date + "`t:`t" + $Note + $Message) }
2 { add-content -path $LogFilePath -value ($Date + "`t:`t" + $Warning + $Message) }
3 { add-content -path $LogFilePath -value ($Date + "`t:`t" + $Problem + $Message) }
default { add-content -path $LogFilePath -value ($Date + "`t:`t" + $Message) }
}
}
Function End-Script
{
param
(
[parameter(Mandatory = $true)]
[String]$Result
)
$PsErrors = $Error
Out-File -InputObject $Result -Filepath $ResultsPath
Out-File -InputObject $PsErrors -FilePath $PSErrorsPath
Write-Log ("********************************")
Write-Log ("***** $($ScriptName) Ends *****")
Write-Log ("********************************")
exit;
}
<#######################################################################################>
#Variable Declarations
$ErrorActionPreference = 'silentlycontinue';
$LabTechCDKey = '@cdkey@';
@API_GetWorkOrder@' | ConvertFrom-JSON;
if (!($DiscoveryJSON))
{
# If we couldn't bring over the JSON object, just set it to the below.
Write-Output "Failed to import DiscoveryJSON.";
End-Script -Result 'Failure15';
}
Else
{
$CompanyName = $DiscoveryJSON.Company_name;
}
$AdminPwd = $DiscoveryJSON.Data.adminPassword;
if (-not $AdminPwd)
{
# Just as a fail-safe
$AdminPwd = "Admin";
}
else
{
$AdminPwd = $AdminPwd.Replace('"', '`"');
}
$InstallErrorPath = "$env:windir\temp\ltinstall\InstallError.txt"
$WorkingDir = "$env:windir\temp\LTInstall"
$LogfilePath = "$WorkingDir\InstallLog.txt"
$InstallDownload = "http://automationfiles.hostedrmm.com/lt_installs/latest_release/installation_assemblies.zip"
$InstallSavePath = "$WorkingDir\LtInstall.zip"
$SqlYogDownload = "http://automationfiles.hostedrmm.com/third_party_apps/sqlyog_103/SQLyog-10.3.0-1Community.exe"
$SqlYogSavePath = "$WorkingDir\SQLyog-10.3.0-1Community.exe"
$ResultsPath = "$WorkingDir\LtInstallResults.txt"
$PSErrorsPath = "$workingDir\LTInstall_PSErrors.txt"
if ($test -eq $true)
{
$RootUser = "Root"
$RootPassword = "wowpass3"
$SQLServerAddress = "LocalHost"
}
else
{
$RootUser = $DiscoveryJSON.data.mysqlUser;
$RootPassword = $DiscoveryJSON.data.mysqlPass;
$SQLServerAddress = $DiscoveryJson.data.MysqlIp;
IF([string]::IsNullOrEmpty($Rootuser) -or [string]::IsNullOrEmpty($RootPassword) -or [string]::IsNullOrEmpty($SqlServerAddress))
{
Write-Output "DiscoveryJSON Was Incomplete.";
End-Script -Result 'Failure15';
}
}
# array that will be used to store any role names that fail to install.
$RolesThatFailedToInstall = @()
# List of features to be installed for Server 2012 R2
$2012R2features = @("AS-Web-Support","AS-WAS-Support","AS-WAS-Support","Web-WebServer","Web-Common-Http",
"Web-Static-Content","Web-Dir-Browsing","Web-Http-Errors","Web-Http-Redirect",
"Web-App-Dev","Web-Asp-Net","Web-Asp-Net45","Web-Net-Ext","Web-Net-Ext45",
"Web-ASP","Web-ISAPI-Ext","Web-ISAPI-Filter","Web-Health","Web-Http-Logging","Web-Performance",
"Web-Basic-Auth","Web-Windows-Auth","Web-Performance","Web-Stat-Compression","Web-Dyn-Compression",
"Web-Mgmt-Tools","Web-Mgmt-Console","Web-Scripting-Tools","Web-Mgmt-Service","Web-Mgmt-Compat",
"Web-Metabase","Web-WMI","Web-Lgcy-Scripting","Web-Lgcy-Mgmt-Console","NET-HTTP-Activation",
"WAS", "WAS-Process-Model", "WAS-NET-Environment", "WAS-Config-APIs")
# List of features to be installed for Server 2012
$2012features = @("Application-Server","AS-Web-Support","AS-WAS-Support","Web-WebServer",
"Web-Common-Http","Web-Static-Content","Web-Dir-Browsing","Web-Http-Errors",
"Web-Http-Redirect","Web-App-Dev","Web-Asp-Net","Web-Asp-Net45",
"Web-Net-Ext","Web-Net-Ext45","Web-ASP","Web-ISAPI-Ext","Web-ISAPI-Filter",
"Web-Health","Web-Http-Logging","Web-Performance","Web-Basic-Auth",
"Web-Windows-Auth","Web-Stat-Compression","Web-Dyn-Compression",
"Web-Mgmt-Tools","Web-Mgmt-Console","Web-Mgmt-Service","Web-Mgmt-Compat","Web-Metabase",
"Web-WMI","Web-Lgcy-Scripting","Web-Lgcy-Mgmt-Console","NET-HTTP-Activation",
"WAS", "WAS-Process-Model", "WAS-NET-Environment", "WAS-Config-APIs")
# List of features to be installed for Server 2008 R2
$2008R2Features = @("Application-Server","AS-Web-Support","AS-WAS-Support","AS-WAS-Support","Web-WebServer",
"Web-Common-Http","Web-Static-Content","Web-Dir-Browsing","Web-Http-Errors","Web-Http-Redirect",
"Web-App-Dev","Web-Asp-Net","Web-Net-Ext","Web-ASP","Web-ISAPI-Ext","Web-ISAPI-Filter",
"Web-Health","Web-Http-Logging","Web-Performance","Web-Basic-Auth","Web-Windows-Auth",
"Web-Performance","Web-Stat-Compression","Web-Dyn-Compression","Web-Mgmt-Tools",
"Web-Mgmt-Console","Web-Scripting-Tools","Web-Mgmt-Service","Web-Mgmt-Compat","Web-Metabase",
"Web-WMI","Web-Lgcy-Scripting","Web-Lgcy-Mgmt-Console","NET-Framework","NET-Framework-Core",
"NET-Win-CFAC","NET-HTTP-Activation","WAS","WAS-Process-Model","WAS-NET-Environment","WAS-Config-APIs")
<#######################################################################################>
#Clean up the directory structure and create a new directory.
Remove-Item -Recurse $WorkingDir -FORCE;
New-Item $WorkingDir -type Directory;
<#
If (!(Test-Path $WorkingDir))
{
Write-Output "Failed to create working directory.";
End-Script -Result 'Failure16';
}
#>
<#######################################################################################>
#Downloads the Install Assemblies
Write-Log "Beginning download of the assemblies."
try
{
$DownloadObj = new-object System.Net.WebClient;
$DownloadObj.DownloadFile($InstallDownload, $InstallSavePath);
}
catch
{
$DownloadErr = $_.Exception.Message;
}
finally
{
if(!(Test-Path $InstallSavePath))
{
Write-Output "Failed to download assemblies. Download exception was: $DownloadErr";
Set-Content $WorkingDir\DownloadErrors.txt $DownloadErr;
End-Script -Result 'Failure01';
}
}
<#######################################################################################>
#Extracts the Install Assemblies and Checks them
Write-Log "Beginning extraction of the assemblies."
Zip-Actions -ZipPath $InstallSavePath -FolderPath $WorkingDir -Unzip $true
$SizeOfFilesInFolder = ((get-childitem $WorkingDir | Measure-Object Length -sum) | `
select @{name='Sum'; expression={[math]::ceiling($_.Sum / 1024 / 1024)}}).Sum;
Write-Output "Verifying that LTInstall folder has extracted files."
IF($SizeOfFilesInFolder -gt 650)
{
Write-Output "All files successfully extracted."
}
ELSE
{
Write-Output "Failed to extract all files. Contents of LTInstall directory were only: $($SizeOfFilesInFolder)";
End-Script -Result 'Failure02';
}
<#######################################################################################>
#Adds Needed Firewall Rules for LabTech
Write-Output "Adding Firewall Rules."
REG.exe ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" /v "IsInstalled" /t REG_DWORD /d 0 /f
REG.exe ADD "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" /v "IsInstalled" /t REG_DWORD /d 0 /f
netsh.exe advfirewall firewall add rule name="LabTech Redirector Port" dir=in description="Required port for LabTech Software functionality" action=allow protocol=tcp localport=70-75
netsh.exe advfirewall firewall add rule name="LabTech Redirector Port" dir=in description="Required port for LabTech Software functionality" action=allow protocol=udp localport=70-75
netsh.exe advfirewall firewall add rule name="IIS Web Port" dir=in description="Required port for LabTech Software functionality" action=allow protocol=tcp localport=80
netsh.exe advfirewall firewall add rule name="IIS SSL Web Port" dir=in description="Required port for LabTech Software functionality" action=allow protocol=tcp localport=443
netsh.exe advfirewall firewall add rule name="LabTech Control Center Database Port" dir=in description="Required port for LabTech Software functionality" action=allow protocol=tcp localport=3306
netsh.exe advfirewall firewall add rule name="LabTech VNC Control Center Ports" dir=in description="Required port for LabTech Software functionality" action=allow protocol=tcp localport=40000-41000
netsh.exe advfirewall firewall add rule name="LabTech Mediator Port" dir=in description="Required port for LabTech Software functionality" action=allow protocol=tcp localport=8002
netsh.exe advfirewall firewall add rule name="LabTech Mediator Port" dir=in description="Required port for LabTech Software functionality" action=allow protocol=udp localport=8002
<#######################################################################################>
#Adds Needed Windows Features
$OS = (Get-WmiObject Win32_OperatingSystem).caption
Import-Module ServerManager;
if($OS -like '*2012 R2*')
{
Process-Features -OS '2012R2'
}
IF($OS -like '*2012*')
{
Process-Features -OS '2012Standard'
}
IF($OS -like '*2008*')
{
Process-Features -OS '2008R2'
}
if ($RolesThatFailedToInstall.count -eq 0)
{
write-output 'All required server roles were successfully installed!'
}
else
{
$FailedRoles = $RolesThatFailedToInstall -join ", ";
Write-Log "The following roles failed to install: $FailedRoles."
out-file -FilePath "$Workingdir\FailedRoles.txt" -InputObject $FailedRoles
End-Script -Result 'Failure03';
}
#####################################################################################
###### Application Pool Default Setting Modifications - Pre-LabTech Installation ####
#####################################################################################
<#
# MB - 9.2.2015 - Disabled this section per Development
Import-Module WebAdministration;
# App pool defaults per:
# https://docs.labtechsoftware.com/LabTech10/Default.htm#Installation_Upgrade/LabTechServerInstallation/LabTech7.0InstallServer2008.htm%3FTocPath%3DGetting%2520Started%7CInstallation%7C_____3
set-ItemProperty IIS:\AppPools\DefaultAppPool managedRuntimeVersion v2.0
set-ItemProperty IIS:\AppPools\DefaultAppPool managedPipelineMode classic
# Permit 32-bit applications and change resetInterval to 00:00:00, per documentation
set-WebConfigurationproperty /System.ApplicationHost/ApplicationPools/ApplicationPoolDefaults[1] -name enable32BitAppOnWin64 -value TRUE;
set-webconfigurationproperty /System.ApplicationHost/ApplicationPools/ApplicationPoolDefaults/cpu -name resetInterval -value '00:00:00';
# Set Idle timeout to 20
Set-ItemProperty ("IIS:\AppPools\DefaultAppPool") -Name processModel.idleTimeout -value ([TimeSpan]::FromMinutes(20))
#Disable HTTP 1.1 Keep-Alives - very important for optimal performance
Set-WebConfiguration -Filter system.webServer/httpProtocol -PSPath MACHINE/WEBROOT/APPHOST -Value @{ allowKeepAlive = $false }
#>
<#######################################################################################>
#Install Visual C++ 2005
Write-Output "Beginning Installation of Visual C++ 2005 Redistributable ........."
$InstallVCRED = New-Object System.Diagnostics.ProcessStartInfo("$WorkingDir\vcredist_x86.exe", "/Q");
$installVcred.UseShellExecute = $False
StartProcWithWait $InstallVCRED;
if(!(gwmi -cl win32_product | where-object { $_.Name -like '*Microsoft Visual C++ 2005*' }))
{
Write-Log "FAILED to install Microsoft Visual C++ 2005 Redistributable ............";
End-Script -Result 'Failure05';
}
ELSE
{
Write-Log "SUCCESSFULLY installed Microsoft Visual C++ 2005 Redistributable .......";
}
<#######################################################################################>
#Install Visual C++ 2010 32 Bit
Write-Output "Beginning Installation of Visual C++ 2010(32 Bit) Redistributable ........."
$InstallVCRED = New-Object System.Diagnostics.ProcessStartInfo("$WorkingDir\vcredist_x86_2010.exe", "/Q");
$installVcred.UseShellExecute = $False
StartProcWithWait $InstallVCRED;
if(!(gwmi -cl win32_product | where-object { $_.Name -like '*Microsoft Visual C++ 2010 x86 Redistributable*' }))
{
Write-Log "FAILED to install Microsoft Visual C++ 2010(32 Bit) Redistributable ............";
End-Script -Result 'Failure05';
}
ELSE
{
Write-Log "SUCCESSFULLY installed Microsoft Visual C++ 2010(32 Bit) Redistributable .......";
}
<#######################################################################################>
#Install Visual C++ 2010 64 Bit
Write-Output "Beginning Installation of Visual C++ 2010(64-Bit) Redistributable ........."
$InstallVCRED = New-Object System.Diagnostics.ProcessStartInfo("$WorkingDir\vcredist_x64.exe", "/Q");
$installVcred.UseShellExecute = $False
StartProcWithWait $InstallVCRED;
if(!(gwmi -cl win32_product | where-object { $_.Name -like '*Microsoft Visual C++ 2010 x64 Redistributable*' }))
{
Write-Log "FAILED to install Microsoft Visual C++ 2010(64 Bit) Redistributable ............";
End-Script -Result 'Failure06';
}
ELSE
{
Write-Log "SUCCESSFULLY installed Microsoft Visual C++ 2010(64 Bit) Redistributable .......";
}
<#######################################################################################>
#Install Crystal Reports
Write-Output "Beginning Installation of Crystal Reports 2008 Runtime SP2 ........"
$InstallCrystal = New-Object System.Diagnostics.ProcessStartInfo("$ENV:windir\system32\msiexec.exe", "/i $WorkingDir\CRRuntime_12_2_mlb.msi /qn /norestart");
$InstallCrystal.UseShellExecute = $False
StartProcWithWait $InstallCrystal;
if(!(gwmi -cl win32_product | where-object { $_.Name -like '*Crystal Reports 2008 Runtime SP2*' }))
{
Write-Log "FAILED to install Crystal Reports 2008 Runtime SP2 ................";
End-Script -Result 'Failure06';
}
ELSE
{
Write-output "SUCCESSFULLY installed Crystal Reports 2008 Runtime SP2 ...........";
}
<#######################################################################################>
#Install .NET 4.0 Extended
if($OS -notlike '*2012*') # 2008 R2 ONLY. 4.0 comes with 4.5 server role on Server 2012+
{
Write-Output "Beginning installation of .NET Framework 4.0 extended .............";
$InstallDotNet4 = New-Object System.Diagnostics.ProcessStartInfo("$WorkingDir\dotnetfx40_full_x86_x64.exe", "/q /norestart");
$InstallDotNet4.UseShellExecute = $False
StartProcWithWait $InstallDotNet4;
if(!(gwmi -cl win32_product | where-object { $_.Name -like '*Microsoft .NET Framework 4*' }))
{
Write-Log "FAILED to install .NET Framework 4.0 ..............................";
End-Script -Result 'Failure07';
}
ELSE
{
Write-output "SUCCESSFULLY installed .NET Framework 4.0 .........................";
}
}
<#######################################################################################>
#Install MySQL ODBC
Write-Log "Beginning installation of MySQL ODBC Connector(32bit) 5.3.4 ...............";
$InstallMySQLODBC32Bit = New-Object System.Diagnostics.ProcessStartInfo("$ENV:windir\system32\msiexec.exe ", "/i $WorkingDir\mysql-connector-odbc-5.3.4-win32.msi /qn /norestart");
$InstallMySQLODBC32Bit.UseShellExecute = $False
StartProcWithWait $InstallMySQLODBC32Bit;
If(!(GP HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.Displayname -like '*MySQL Connector/ODBC 5.3*'}))
{
Write-Log "FAILED to install MySQL ODBC Connector ............................";
End-Script -Result 'Failure09';
}
Write-Log "Beginning installation of MySQL ODBC Connector(64bit) 5.3.4 ...............";
$InstallMySQLODBC64Bit = New-Object System.Diagnostics.ProcessStartInfo("$ENV:windir\system32\msiexec.exe ", "/i $WorkingDir\mysql-odbc-5.3.4-winx64.msi /qn /norestart");
$InstallMySQLODBC64Bit.UseShellExecute = $False
StartProcWithWait $InstallMySQLODBC64Bit;
If(!(gp HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.Displayname -like '*MySQL Connector/ODBC 5.3*'}))
{
Write-Log "FAILED to install MySQL ODBC Connector ............................";
End-Script -Result 'Failure10';
}
Write-Log "Beginning installation of MySQL NET Connector(32bit) 6.9.7 ...............";
$InstallMySQLODBCNET = New-Object System.Diagnostics.ProcessStartInfo("$ENV:windir\system32\msiexec.exe ", "/i $WorkingDir\mysql-net-6.9.7.msi /qn /norestart");
$InstallMySQLODBCNET.UseShellExecute = $False
StartProcWithWait $InstallMySQLODBCNET;
If(!(GP HKLM:\Software\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object {$_.Displayname -like '*MySQL Connector Net 6.9.*'}))
{
Write-Log "FAILED to install MySQL Connector Net 6.9 ............................";
End-Script -Result 'Failure11';
}
ELSE
{
Write-Log "SUCCESSFULLY installed MySQL Connector Net 6.9 .......................";
}
<#######################################################################################>
#Install LabTech Server
Write-Output "Beginning installation of LabTech Server ..........................";
$InstallLabTech = New-Object System.Diagnostics.ProcessStartInfo("$ENV:windir\system32\msiexec.exe", "/i `"$WorkingDir\InstallServer.msi`" /qn /norestart /L*V `"$WorkingDir\LT_Install_Log.txt`" CDKEYTEXT=`"$($LabTechCDKey)`" MYSQLSERVERADDRESS=`"$SQLServerAddress`" MYSQLROOTUSER=`"$RootUser`" MySqlRootPassword=`"$RootPassword`" LTADMINPASSWORD=`"$AdminPwd`" LABTECHIGNITE=1 LTADMINWEBACCESS=1");
$InstallLabTech.UseShellExecute = $False
StartProcWithWait $InstallLabTech;
<#######################################################################################>
#Check for Errors
if(!(gwmi -cl win32_product | where-object { $_.Name -like '*LabTech® Software*' }))
{
If (Test-Path -Path "$WorkingDir\LT_Install_Log.txt")
{
$InstallLog = Get-Content -Path "$WorkingDir\LT_Install_Log.txt" | out-string
$ErrorRegex = "(?:INSTALLATION ERROR BEGIN[\s][\s\S]+[\d\d:]+\d+.[\d]+:\s)([\s\S]+)(?:Action\sLog\s)"
$InstallError = ([regex]::matches($InstallLog, $ErrorRegex)).groups[1].value
If($InstallError)
{
Out-File -FilePath $InstallErrorPath -InputObject $InstallError
Write-Log "FAILED to install LabTech Server ..................................";
End-Script -Result 'Failure11';
}
Write-Log "No Install Error Could Be Parsed .................................."
Write-Log "FAILED to install LabTech Server ..................................";
End-Script -Result 'Failure12';
}
Else
{
Write-Log "No Install Log was found .................................."
Write-Log "FAILED to install LabTech Server ..................................";
End-Script -Result 'Failure13';
}
}
ELSE
{
Write-Log "SUCCESSFULLY installed LabTech Server .............................";
}
###############################################################################
# Create the Robots.txt file
# This prevent crawlers from picking up this LabTech server's web components.
###############################################################################
Set-Content "${env:SystemDrive}\inetpub\wwwroot\robots.txt" "User-agent: *`r`nDisallow: /";
set-ItemProperty -PATH "HKLM:\SYSTEM\CurrentControlSet\services\Tcpip\Parameters" -NAME EnableTCPChimney -Value 0
set-ItemProperty -PATH "HKLM:\SYSTEM\CurrentControlSet\services\Tcpip\Parameters" -NAME MaxUserPort -Value 65534
set-ItemProperty -PATH "HKLM:\SYSTEM\CurrentControlSet\services\Tcpip\Parameters" -NAME TcpTimedWaitDelay -Value 30
set-ItemProperty -PATH "HKLM:\SYSTEM\CurrentControlSet\services\Tcpip\Parameters" -NAME ReservedPorts -Value '3306-3306,8000-9024,40000-40100'
<#######################################################################################>
#Install SQLYog
$DownloadObj = new-object System.Net.WebClient;
$DownloadObj.DownloadFile($SqlYogDownload, $SqlYogSavePath);
$InstallYog = New-Object System.Diagnostics.ProcessStartInfo("$SqlYogSavePath","/S");
$InstallYog.UseShellExecute = $False
StartProcWithWait $InstallYog;
End-Script -Result "LabTech Installation Process Completed!";