-
Notifications
You must be signed in to change notification settings - Fork 50
/
vCAC62-PreReq-Automation.ps1
528 lines (453 loc) · 25.8 KB
/
vCAC62-PreReq-Automation.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
#==============================================
# Generated On: 12/4/2014 9:46 AM
# Generated By: Brian Graf
# Technical Marketing Engineer - Automation
# Organization: VMware
# Twitter: @vTagion
# vRA 6.2 Pre-Req Automation Script v1
#==============================================
#----------------------------------------------
#==================USAGE=======================
# For Windows Server 2008 & 2012
# This script has been created to aid in
# Configuring the settings for the vRA 6.2
# Pre-Req Checker. This script will set all
# Pre-Req's except for enabling TCP/IP in
# MS SQL, chich needs to be performed manually
# And the services will need to be restarted.
#----------------------------------------------
#===============REQUIREMENTS===================
# For this script to run successfully be sure:
# *To run PowerShell as administrator
# *To have admin rights on the server
#----------------------------------------------
#=============EDITOR'S NOTE====================
# In order for this script to work on servers that
# have proxied or restricted access to the Internet,
# it is necessary to configure a local source repository
# or else the features and roles requiring .NET 3.5 will fail.
# To do so, configure the variable called $InstallSource
# below making sure to set the path appropriately. In
# this example, the source is provided by mounting the
# installation CD as drive D.
# - Chip Zoller, Senior Virtualization Engineer, Worldpay US
# ----------------------------------------
# USER CONFIGURATION - EDIT AS NEEDED
# ----------------------------------------
# Set IIS default locations to be used with IIS role
$InetPubRoot = "C:\Inetpub"
$InetPubLog = "C:\Inetpub\Log"
$InetPubWWWRoot = "C:\Inetpub\WWWRoot"
# Specify what the installer will do if .NET is not 4.5.2
# 1 - use a local .NET installer, 2 - Auto-Download from the internet and proceed , 3 - Exit the script
$menuoption = ""
$dotnetlocalpath = ""
# ------------- Server 2012 ---------------
# Specify what the installer will do for installing framework components
# 1 - use a local 2012 iso sources folder, 2 - Auto-Download from Microsoft servers internet and proceed , 3 - Exit the script
$frameworkmenuoption = ""
# Set install source location if unable to directly connect to the Internet
# Example of Mounted 2012 ISO source path (ex D:\sources\sxs)
$InstallSource = ""
# This applies ONLY to 2012
#Specify how you would like to obtain and run NTRights.exe
# 1 - use a local NTRights.exe file , 2 - Auto-Download from the internet and proceed , 3 - Exit the script
$NTRightsmenuoption = ""
#Example C:\Temp\NTRights.exe
$NTRightsInstallSource = ""
#Account to use for Batch Logon and Secondary Logon Services (if left blank will default to local administrators group)
# Example Corp\vcacservice or Eng\Smithj
$domainAdminAcct = ""
# Specify what the installer will do if Java is not 1.7
# 1 - use a local Java installer, 2 - Auto-Download from the internet and proceed , 3 - Exit the script
$javamenuoption = ""
$javalocalpath = ""
# ----------------------------------------
# END OF USER CONFIGURATION
# ----------------------------------------
# ----Do not modify beyond this point-----
$ErrorActionPreference="SilentlyContinue"
$ErrorActionPreference="Continue"
# ----------------------------------------
# CHECK POWERSHELL SESSION
# ----------------------------------------
$Elevated = New-Object Security.Principal.WindowsPrincipal( [Security.Principal.WindowsIdentity]::GetCurrent() )
& {
if ($Elevated.IsInRole( [Security.Principal.WindowsBuiltInRole]::Administrator ))
{
write-host "PowerShell is running as an administrator." -ForegroundColor Green
} Else {
throw "Powershell must be run as an adminstrator."
}
if( [IntPtr]::size * 8 -eq 64 )
{
Write-Host "You are running 64-bit PowerShell" -ForegroundColor Green
}
else
{
Write-Host "You are running 32-bit PowerShell" -ForegroundColor Red
Throw "Please run using 64-bit PowerShell as administrator"
}
}
# ----------------------------------------
# END OF POWERSHELL CHECK
# ----------------------------------------
# ----------------------------------------
# CHECK FOR .NET FRAMEWORK
# ----------------------------------------
# .NET FRAMEWORK 4.5.2 is required for vRA 6.2 to run properly
# Check to see if .Net 4.5.2 is present
$DNVersion = Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse | Get-ItemProperty -name Version -EA 0 | Where-Object { $_.PSChildName -match '^(?!S)\p{L}'} | Sort-Object version -Descending | Select-Object -ExpandProperty Version -First 1
$DNVersions = $DNVersion.Split(".")
$DNVersionMajor = $DNVersions[0]
$DNVersionMinor = $DNVersions[1]
$DNVersionBuild = $DNVersions[2]
# If .Net is older than 4.5, stop installer until .Net is upgraded
# .NET Framework 4.5.2 Build is 4.5.51209
if ($DNVersionMajor -eq 4 -and $DNVersionMinor -eq 5 -and $DNVersionBuild -ge 51209 ){ Write-Host ".NET version on this server is $DNVersion " -ForegroundColor Green
}else{
Write-Host "vRA 6.2 requires .Net framework version 4.5.2 to continue" -ForegroundColor Red
if ($menuoption -eq ""){
do{
Write-Host "
(1) - I have the .Net 4.5.2 installer and want to install it from a local folder
(2) - I have internet access and want to download and install it automatically
(3) - Exit this script" -ForegroundColor Yellow
$menuoption = read-Host -Prompt "Choose a number to proceed: "
} Until ($menuoption -eq "1" -or $menuoption -eq "2" -or $menuoption -eq "3")}
Switch ($menuoption){
"1" {
do {
$dotnetlocalpath = Read-Host -Prompt "Unable to locate file. Where is the .NET 4.5.2 installer located locally? (example c:\temp\dotnetinstaller.exe)"
} Until ((Test-path -Path $dotnetlocalpath -ErrorAction SilentlyContinue) -eq $true)
Write-Host "Attempting to Install .NET 4.5.2. Please be patient." -ForegroundColor Green
Write-Verbose ""
$InstallDotNet = Start-Process $dotnetlocalpath -ArgumentList "/q /norestart" -Wait -PassThru
Write-Host "Dot Net Installation finished. Proceeding with Server configuration." -ForegroundColor Green
}
"2" {
if (!(test-path -Path "c:\Temp")){
Write-Host "Creating folder C:\Temp" -ForegroundColor Green
New-Item -ItemType Directory -Force -Path "C:\Temp"
}
Write-Host "Preparing to Download .NET 4.5.2" -ForegroundColor Green
Write-Host "Attempting to Download .NET 4.5.2. Please be patient." -ForegroundColor Green
$download = New-Object Net.WebClient
$url = "http://download.microsoft.com/download/E/2/1/E21644B5-2DF2-47C2-91BD-63C560427900/NDP452-KB2901907-x86-x64-AllOS-ENU.exe"
$file = ("C:\Temp\DotNet452.exe")
$download.Downloadfile($url,$file)
if (!(Test-Path -Path "C:\Temp\DotNet452.exe")) {Write-Host "Uh Oh. For some reason we were unable to download the .NET Installer correctly" -ForegroundColor Yellow
Throw "Please check your internet connection and rerun this script" } else {Write-Host "File downloaded successfully... Proceeding" -ForegroundColor Green}
Write-Host "Attempting to Install .NET 4.5.2. Please be patient." -ForegroundColor Green
Write-Verbose ""
$InstallDotNet = Start-Process $file -ArgumentList "/q /norestart" -Wait -PassThru
Write-Host "Dot Net Installation finished. Proceeding with Server configuration." -ForegroundColor Green
}
"3" { Exit }
}
# }
}
# ---------------------------------------
# END OF .NET FRAMEWORK CHECK
# ---------------------------------------
# ---------------------------------------
# Check Operating System Version
# ---------------------------------------
# Grab the OS Name
$os = (get-WMiObject -class Win32_OperatingSystem).caption
# Overwrite $OS variable with smaller string
switch -wildcard ($os) {
"*2008*" {
Write-Host "OS = $os" -ForegroundColor Green
$os = "2008"
}
"*2012*" {
Write-Host "OS = $os" -ForegroundColor Green
$os = "2012"
}
Default {Write-Host "The current operating system, $os, is not supported at this time" }
}
# ---------------------------------------
# END OF OS VERSION CHECK
# ---------------------------------------
# Begin installations
# ----------------------------------------
# BEGIN ROLE AND FEATURE INSTALL
# ----------------------------------------
# Loading feature installation modules
Write-Host "Importing Server Manager " -ForegroundColor Yellow
Import-Module ServerManager
Write-Host "Installing IIS roles " -ForegroundColor Yellow
if ($os -eq "2008") {
# Installing roles specified in vCAC 6 Pre-req checker
Add-WindowsFeature -Name Web-Webserver,Web-Http-Redirect,Web-Asp-Net,Web-Windows-Auth,Web-Mgmt-Console,Web-Mgmt-Compat, web-metabase
}
if ($os -eq "2012"){
if ($frameworkmenuoption -eq ""){
do{
Write-Host "
(1) - I have the Server 2012 ISO mounted and want to install the framework files from a local folder
(2) - I have internet access and want to download it from Microsoft and install it automatically
(3) - Exit this script" -ForegroundColor Yellow
$frameworkmenuoption = read-Host -Prompt "Choose a number to proceed: "
} Until ($frameworkmenuoption -eq "1" -or $frameworkmenuoption -eq "2" -or $frameworkmenuoption -eq "3")}
Switch ($frameworkmenuoption){
"1" {
do {
$InstallSource = Read-Host -Prompt "Unable to locate folder. Please specify the source folder for required files (ex D:\sources\sxs\)"
} Until ((Test-path -Path $InstallSource -ErrorAction SilentlyContinue) -eq $true)
Write-Host "Attempting to Install .NET Framework. Please be patient." -ForegroundColor Green
Add-WindowsFeature -Name Web-Webserver,Web-Http-Redirect,Web-Asp-Net,Web-Windows-Auth,Web-Mgmt-Console,Web-Mgmt-Compat, web-metabase -Source $InstallSource
}
"2" {
Write-Host "Preparing to Download Framework Components" -ForegroundColor Green
Write-Host "Attempting to Download Framework Components. Please be patient. (~200MB)" -ForegroundColor Green
if (Test-Connection google.com -Count 3 -ErrorAction SilentlyContinue) {Write-Host "Internet Connection Succeeded." -ForegroundColor Green}
Add-WindowsFeature -Name Web-Webserver,Web-Http-Redirect,Web-Asp-Net,Web-Windows-Auth,Web-Mgmt-Console,Web-Mgmt-Compat, web-metabase
Write-Host "Framework finished. Proceeding with Server configuration." -ForegroundColor Green
}
"3" { Exit }
}
# }
}
Write-Host "IIS role installation complete, adding features... " -ForegroundColor Green
# ---------------------------------------
# Install Correct Framework
# ---------------------------------------
# Run the correct command based off the OS result
switch ($os) {
"2008" {
# Adding 2008 features specified in vCAC 6 Pre-req checker
Write-Host "Adding Windows features " -ForegroundColor Yellow
Add-WindowsFeature -Name AS-Net-framework, NET-Win-CFAC, NET-HTTP-Activation, NET-Non-HTTP-Activ
Write-Host "Features installation complete, loading IIS module " -ForegroundColor Green
}
"2012" {
# Adding 2012 features specified in vCAC 6 Pre-req checker
Write-Host "Adding Windows features " -ForegroundColor Yellow
Install-WindowsFeature -name NET-Framework-Core,net-wcf-http-activation45
Add-windowsfeature -name was, was-config-apis, was-Net-Environment,NET-Non-HTTP-Activ
Write-Host "Features installation complete, loading IIS module " -ForegroundColor Green}
Default {Write-Host "The Operating System does not appear to be compatible with this script"
Throw "This is for Windows Server 2008 and 2012"
}
}
# ---------------------------------------
# END OF Framework Installation
# ---------------------------------------
# Loading IIS web admin module
if (Get-Module -ListAvailable WebAdministration){
Write-host "Importing Web Admin module " -Foregroundcolor Yellow
Import-Module WebAdministration
}
else {
throw "Webadministration is not installed on this system"
}
# Build the IIS folder structure
Write-Host "Setting up folder structure" -ForegroundColor Yellow
New-Item -Path $InetPubRoot -type directory -Force -ErrorAction SilentlyContinue
New-Item -Path $InetPubLog -type directory -Force -ErrorAction SilentlyContinue
New-Item -Path $InetPubWWWRoot -type directory -Force -ErrorAction SilentlyContinue
# Set the directory access for 'Builtin\IIS_IUSRS' and 'NT SERVICE\TrustedInstaller'
$Command = "icacls $InetPubWWWRoot /grant BUILTIN\IIS_IUSRS:(OI)(CI)(RX) BUILTIN\Users:(OI)(CI)(RX)"
cmd.exe /c $Command
$Command = "icacls $InetPubLog /grant ""NT SERVICE\TrustedInstaller"":(OI)(CI)(F)"
cmd.exe /c $Command
# Setting the default website location used in vCAC
Set-ItemProperty 'IIS:\Sites\Default Web Site' -name physicalPath -value $InetPubWWWRoot
# Setting authentication values for IIS
# Anonymous Authentication needs to be disabled
# Windows Authentication needs to be enabled
Write-Host "Setting authentication values for IIS" -ForegroundColor Yellow
Set-WebConfigurationProperty -Location 'Default Web Site' -Filter /system.webServer/security/authentication/AnonymousAuthentication -Name Enabled -Value $true
Set-WebConfigurationProperty -Location 'Default Web Site' -Filter /system.webServer/security/authentication/AnonymousAuthentication -Name Enabled -Value $false
Set-WebConfigurationProperty -Location 'Default Web Site' -Filter /system.webServer/security/authentication/windowsAuthentication -Name Enabled -Value $false
Set-WebConfigurationProperty -Location 'Default Web Site' -Filter /system.webServer/security/authentication/windowsAuthentication -Name Enabled -Value $true
# Sometimes the pre-req checker cannot distinguish the values of the Windows authentication without
# The providers being removed and added back in.
# Removing and re-adding Windows authentication providers
Write-Host "Removing & Re-Adding Windows authentication providers" -ForegroundColor Yellow
# Authentication Providers code by Jonathan Medd http://www.jonathanmedd.net
Get-WebConfigurationProperty -Filter system.webServer/security/authentication/WindowsAuthentication -Location 'Default Web Site' -Name providers.Collection | Select-Object -ExpandProperty Value | ForEach-Object {Remove-WebConfigurationProperty -Filter system.webServer/security/authentication/WindowsAuthentication -Location 'Default Web Site' -Name providers.Collection -AtElement @{value=$_}}
Add-WebConfigurationProperty -Filter system.webServer/security/authentication/WindowsAuthentication -Location 'Default Web Site' -Name providers.Collection -AtIndex 0 -Value "Negotiate"
Add-WebConfigurationProperty -Filter system.webServer/security/authentication/WindowsAuthentication -Location 'Default Web Site' -Name providers.Collection -AtIndex 1 -Value "NTLM"
# Extended protection needs to be enabled and disabled for vCAC to recognize the value
# Enable and disable the Extended Protection
Write-Host "Enabling and disabling Extended Protection" -ForegroundColor Yellow
Set-WebConfigurationProperty -Filter system.webServer/security/authentication/WindowsAuthentication -Location 'Default Web Site' -Name extendedProtection.tokenChecking -Value 'Allow'
Set-WebConfigurationProperty -Filter system.webServer/security/authentication/WindowsAuthentication -Location 'Default Web Site' -Name extendedProtection.tokenChecking -Value 'None'
# The same must happen with Kernel-Mode. This will disable then re-enable the value
# Resetting KERNEL MODE
Write-Host "Resetting Kernel Mode" -ForegroundColor Yellow
Set-WebConfigurationProperty -Filter system.webServer/security/authentication/WindowsAuthentication -Location 'Default Web Site' -Name useKernelMode -Value $false
Set-WebConfigurationProperty -Filter system.webServer/security/authentication/WindowsAuthentication -Location 'Default Web Site' -Name useKernelMode -Value $true
# IIS must be restarted for the changes to take effect
# Resetting IIS
Write-Host "Resetting IIS" -ForegroundColor Yellow
$Command = "IISRESET"
Invoke-Expression -Command $Command
Write-Host "IIS Reset Complete..." -ForegroundColor Green
# ----------------------------------------
# END OF ROLE & FEATURE INSTALL
# ----------------------------------------
# ----------------------------------------
# FIREWALL & SECURITY SETTINGS
# ----------------------------------------
# MSDTC is used for Coordinating Transactions spanning several resource managers (databases, message queues, etc)
# The following settings will allow vCAC to function properly on the network.
# Setting the MSDTC components
Write-Host "Setting MSDTC components in the registry. Please restart your system after installation completes" -ForegroundColor Yellow
Set-ItemProperty -Path HKLM:\Software\Microsoft\MSDTC\Security -Name LuTransactions -Value 1
Set-ItemProperty -Path HKLM:\Software\Microsoft\MSDTC\Security -Name NetworkDtcAccess -Value 1
Set-ItemProperty -Path HKLM:\Software\Microsoft\MSDTC\Security -Name NetworkDtcAccessInbound -Value 1
Set-ItemProperty -Path HKLM:\Software\Microsoft\MSDTC\Security -Name NetworkDtcAccessOutbound -Value 1
Set-ItemProperty -Path HKLM:\Software\Microsoft\MSDTC\Security -Name NetworkDtcClients -Value 1
Set-ItemProperty -Path HKLM:\Software\Microsoft\MSDTC\Security -Name NetworkDtcAccessTransactions -Value 1
Set-ItemProperty -Path HKLM:\Software\Microsoft\MSDTC\Security -Name NetworkDtcAccessAdmin -Value 1
Set-ItemProperty -Path HKLM:\Software\Microsoft\MSDTC\Security -Name NetworkDtcAccessClients -Value 1
# The Distributed Transaction Coordinator needs to have access through the firewall
# The following line of code is all that we will use. (If the firewall is enabled it
# Will utilize the rule, if the firewall is disabled, this can be ignored
# Creating firewall rule for DTC
#netsh advfirewall firewall set rule group="Distributed Transaction Coordinator" new enable=Yes | Out-Null
netsh advfirewall firewall set rule group="Distributed Transaction Coordinator" new enable=Yes
# ----------------------------------------
# END FIREWALL & SECURITY SETTINGS
# ----------------------------------------
# ----------------------------------------
# LOGON SERVICE SETTINGS
# ----------------------------------------
# Enabling Secondary Logon service
# If the 'Secondary Logon' service is not running, this will set the service to
# Automatic and start the service
Write-Host "Enabling Secondary Logon Service" -ForegroundColor Yellow
if ((Get-Service seclogon).Status -ne 'Running'){
Set-Service Seclogon -StartupType Automatic
Start-Service seclogon
Write-Host "Secondary Logon Service Enabled..." -ForegroundColor Yellow
}
if ($NTRightsmenuoption -eq ""){
do{
Write-Host "
(1) - I have the NTRights.exe and want to run the file from a local folder
(2) - I have internet access and want to download it from the internet automatically
(3) - Exit this script" -ForegroundColor Yellow
$NTRightsmenuoption = read-Host -Prompt "Choose a number to proceed: "
} Until ($NTRightsmenuoption -eq "1" -or $NTRightsmenuoption -eq "2" -or $NTRightsmenuoption -eq "3")}
Switch ($NTRightsmenuoption){
"1" {
do {
$NTRightsInstallSource = Read-Host -Prompt "Unable to locate file. Please specify the location of ntrights.exe(ex c:\temp\ntrights.exe)"
} Until ((Test-path -Path $NTRightsInstallSource -ErrorAction SilentlyContinue) -eq $true)
Write-Host "Attempting to run NTRights.exe." -ForegroundColor Yellow
if ($domainAdminAcct -eq "") {$domainAdminAcct = read-Host -Prompt "What is the domain admin account for vCAC-IAAS? (ex. Corp\Services) " }
Write-Host "Account specified for Batch Logon and Secondary Service Logon is $domainAdminAcct" -ForegroundColor Yellow
}
"2" {
Write-Host "Preparing to Download NTrights.exe" -ForegroundColor Green
Write-Host "Attempting to Download NTrights.exe." -ForegroundColor Green
if (!(test-path -Path "c:\Temp")){
Write-Host "Creating folder C:\Temp" -ForegroundColor Green
New-Item -ItemType Directory -Force -Path "C:\Temp"
}
if (Test-Connection google.com -Count 3 -ErrorAction SilentlyContinue) {Write-Host "Internet Connection Succeeded." -ForegroundColor Green}
$downloadNTRights = New-Object Net.WebClient
$NTRightsurl = "http://download.microsoft.com/download/8/e/c/8ec3a7d8-05b4-440a-a71e-ca3ee25fe057/rktools.exe"
$NTRightsfile = ("C:\Temp\rktools.exe")
$downloadNTRights.Downloadfile($NTRightsurl,$NTRightsfile)
if (!(Test-Path -Path "C:\Temp\rktools.exe")) {Write-Host "Uh Oh. For some reason we were unable to download rktools.exe correctly" -ForegroundColor Yellow
Throw "Please check your internet connection and rerun this script" } else {Write-Host "File downloaded successfully... Proceeding" -ForegroundColor Green}
c:\Temp\rktools.exe /C /T:c:\temp
Start-Sleep -Seconds 5
if (!(Test-Path -Path "C:\Temp\rktools.msi")) {Write-Host "Uh Oh. For some reason rktools.msi didn't unpack correctly" -ForegroundColor Yellow
Throw "There appears to be an issue with the rktools.exe, you may need to extract the rktools and place ntrights.exe in the c:\temp folder manually and rerun this script" } else {Write-Host "rktools.msi unpacked successfully" -ForegroundColor Green}
msiexec /i c:\Temp\rktools.msi /Qb
Write-Host "Waiting for ntrights.exe to appear in C:\Program Files (x86)\Windows Resource Kits\Tools\"
do {Start-Sleep -Seconds 5} until (Test-Path -path "C:\Program Files (x86)\Windows Resource Kits\Tools\ntrights.exe" -ErrorAction SilentlyContinue)
Copy-Item "C:\Program Files (x86)\Windows Resource Kits\Tools\ntrights.exe" c:\temp\ntrights.exe -force
Start-Sleep -Seconds 2
if ($domainAdminAcct -eq "") {$domainAdminAcct = read-Host -Prompt "What is the domain admin account for vCAC-IAAS? (ex. Corp\Services) " }
Write-Host "Account specified for Batch Logon and Secondary Service Logon is $domainAdminAcct" -ForegroundColor Yellow
$NTRightsInstallSource = "C:\Temp\NTRights.exe"
}
"3" { Exit }
}
Write-Host "Setting Batch Logon Rights" -ForegroundColor Yellow
#iex "c:\Temp\NTRights.exe +r SeBatchLogonRight -u $domainAdminAcct"
iex "$NTRightsInstallSource +r SeBatchLogonRight -u $domainAdminAcct"
Write-Host "Setting Secondary Logon Rights" -ForegroundColor Yellow
#iex "c:\Temp\NTRights.exe +r SeServiceLogonRight -u $domainAdminAcct"
iex "$NTRightsInstallSource +r SeServiceLogonRight -u $domainAdminAcct"
# ----------------------------------------
# END LOGON SERVICE SETTINGS
# ----------------------------------------
# All Windows settings are now set for vCAC to install correctly
# After SQL Server is installed, make sure to enable TCP/IP and
# Restart the SQL services
# ----------------------------------------
# JAVA INSTALL & CONFIG
# ----------------------------------------
Write-Host "Java Section " -ForegroundColor Yellow
if (dir "HKLM:\SOFTWARE\JavaSoft\Java Runtime Environment" -ErrorAction SilentlyContinue){
$JavaVersion = dir "HKLM:\SOFTWARE\JavaSoft\Java Runtime Environment" | select -expa pschildname -Last 1
$JavaVersions = $JavaVersion.Split(".")
$JavaVersionMajor = $JavaVersions[0]
$JavaVersionMinor = $JavaVersions[1]
$JavaVersionBuild = $JavaVersions[2]
} else {$javaversionmajor = 0}
# If .Net is older than 4.5, stop installer until .Net is upgraded
if ($JavaVersionMajor -eq 1 -and $JavaVersionMinor -ge 7 ){ Write-Host "Java version on this server is $JavaVersion " -ForegroundColor Green
}else{
Write-Host "vRA 6.2 requires Java JRE 1.7 64-bit or higher" -ForegroundColor Red
if ($javamenuoption -eq ""){
do{
Write-Host "
(1) - I have the Java JRE 1.7 or higher and want to install it from a local folder
(2) - I have internet access and want to download and install it automatically
(3) - Exit this script" -ForegroundColor Yellow
$javamenuoption = read-Host -Prompt "Choose a number to proceed: "
} Until ($javamenuoption -eq "1" -or $javamenuoption -eq "2" -or $javamenuoption -eq "3")}
Switch ($javamenuoption){
"1" {
do {
$javalocalpath = Read-Host -Prompt "Unable to locate file. Where is the Java installer located locally? (example c:\temp\jre71.exe)"
} Until ((Test-path -Path $javalocalpath -ErrorAction SilentlyContinue) -eq $true)
Write-Host "Attempting to Install Java. Please be patient." -ForegroundColor Green
Write-Verbose ""
$InstallJava = Start-Process $javalocalpath -ArgumentList "/s" -Wait -PassThru
Write-Host "Java installation finished. Proceeding with script." -ForegroundColor Green
}
"2" {
if (!(test-path -Path "c:\Temp")){
Write-Host "Creating folder C:\Temp" -ForegroundColor Green
New-Item -ItemType Directory -Force -Path "C:\Temp"
}
Write-Host "Preparing to Download Java JRE 1.7" -ForegroundColor Green
Write-Host "Attempting to Download Java. Please be patient." -ForegroundColor Green
$downloadjava = New-Object Net.WebClient
$javaurl = "http://javadl.sun.com/webapps/download/AutoDL?BundleId=95125"
$javafile = ("C:\Temp\javajre17.exe")
$downloadjava.Downloadfile($javaurl,$javafile)
if (!(Test-Path -Path "C:\Temp\javajre17.exe")) {Write-Host "Uh Oh. For some reason we were unable to download the Java installer correctly" -ForegroundColor Yellow
Throw "Please check your internet connection and rerun this script" } else {Write-Host "File downloaded successfully... Proceeding" -ForegroundColor Green}
Write-Host "Attempting to Install Java. Please be patient." -ForegroundColor Green
Write-Verbose ""
$InstallJava = Start-Process $javafile -ArgumentList "/s" -Wait -PassThru
Write-Host "Java installation finished. Proceeding with script." -ForegroundColor Green
}
"3" { Exit }
}
# }
}
Write-Host "Setting Java_HOME variable to C:\Program Files\Java\jre7" -ForegroundColor Green
setx /M JAVA_HOME "C:\Program Files\Java\jre7"
Write-Host "Java_HOME variable set." -ForegroundColor Green
# ----------------------------------------
# END JAVA INSTALL & CONFIG
# ----------------------------------------
Write-Host ""
Write-Host "Pre-Req settings have been completed." -foregroundcolor Green
Write-Host "Please run the prerequisite checker and verify. Proceed with SQL pre-reqs" -ForegroundColor Green
# ----------------------------------------
# END OF SCRIPT
# ----------------------------------------