Version 3.0 initial commit

- Support for vSphere 6.5 & 6.7
- Support for Windows Server 2016
- Removed support for Windows Server 2008
- Added Email notification for VC & DC build. Specify destination address & SMTP server in autolmate.ini
- Changed router to pfSense
- Updated NAS to FreeNAS 11.1
- Support for View 7.5
- Nested 2008, 2016, Windows 7, Windows 8, & Windows 10 VMs
master
DemitasseNZ 2018-06-24 16:42:53 +12:00
parent ce80804955
commit 945c87edba
80 changed files with 1803 additions and 1164 deletions

View File

@ -11,22 +11,11 @@ if (Test-Path C:\PSFunctions.ps1) {
Read-Host "Press <Enter> to exit" Read-Host "Press <Enter> to exit"
exit exit
} }
#if ((Test-Administrator) -and (Test-Path "C:\Program Files\VMware\VMware Tools\VMwareToolboxCmd.exe")) {
# Write-BuildLog " "
# Write-BuildLog "This script should not be 'Run As Administrator'"
# Write-BuildLog " "
# Write-BuildLog "Just double click the shortcut"
# Write-BuildLog " "
# Read-Host "Press <Enter> to exit"
# exit
#}
$a = (Get-Host).UI.RawUI $a = (Get-Host).UI.RawUI
$b = $a.WindowSize $b = $a.WindowSize
$b.Height = $a.MaxWindowSize.Height -1 $b.Height = $a.MaxWindowSize.Height -1
$a.WindowSize = $b $a.WindowSize = $b
# WASP is a 64bit plugin, the Guest Cust. PowerCLI commands are only 32bit
#import-module C:\windows\system32\WASP.dll
#select-window -Title "Administrator: C:\*" | set-windowposition -left 3 -top 3
$Subnet = ((Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName .).IPAddress[0]).split(".")[2] $Subnet = ((Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter IPEnabled=TRUE -ComputerName .).IPAddress[0]).split(".")[2]
If ($Subnet -eq "199") { If ($Subnet -eq "199") {
@ -44,18 +33,18 @@ If ($Subnet -eq "201") {
$SRM = $True $SRM = $True
} }
if ((Get-Service vpxd).Status -eq "Starting") { if ((Get-Service vpxd -ErrorAction SilentlyContinue).Status -eq "Starting") {
Write-BuildLog "The vCenter service is still starting; script will pause until service has started." Write-BuildLog "The vCenter service is still starting; script will pause until service has started."
do { do {
Start-Sleep -Seconds 30 Start-Sleep -Seconds 30
} until ((Get-Service vpxd).Status -eq "Running") } until ((Get-Service vpxd).Status -eq "Running")
} elseif ((Get-Service vpxd).Status -eq "Stopped") { } elseif ((Get-Service vpxd -ErrorAction SilentlyContinue).Status -eq "Stopped") {
Write-BuildLog "The vCenter service is stopped. Please verify the DC VM is powered on and databases have started." Write-BuildLog "The vCenter service is stopped. Please verify the DC VM is powered on and databases have started."
Read-Host "Press <Enter> to exit" Read-Host "Press <Enter> to exit"
exit exit
} }
if ((Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $null) { if (((Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $null) -and ((Get-Module -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $null)) {
try { try {
Write-BuildLog "Loading PowerCLI plugin, this may take a little while." Write-BuildLog "Loading PowerCLI plugin, this may take a little while."
Add-PSSnapin VMware.VimAutomation.Core Add-PSSnapin VMware.VimAutomation.Core
@ -65,6 +54,10 @@ if ((Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue)
Read-Host "Press <Enter> to exit" Read-Host "Press <Enter> to exit"
exit exit
} }
} else {
$p += ";C:\Program Files (x86)\VMware\Infrastructure\PowerCLI\Modules"
[Environment]::SetEnvironmentVariable("PSModulePath",$p)
Import-Module "VMware.VimAutomation.Core" -ErrorAction SilentlyContinue
} }
for ($i=1;$i -le 4; $i++) { for ($i=1;$i -le 4; $i++) {
$vmhost = "$HostPrefix$i.lab.local" $vmhost = "$HostPrefix$i.lab.local"
@ -77,11 +70,10 @@ for ($i=1;$i -le 4; $i++) {
} }
} }
If (!($MaxHosts -ge 2)){ If (!($MaxHosts -ge 2)){
Write-Host "Couldn't find first two hosts to build, need host1 & host2 built before running this script" Write-BuildLog "Couldn't find first two hosts to build, need host1 & host2 built before running this script"
Read-Host "Build the hosts & rerun this script" Read-Host "Build the hosts & rerun this script"
Exit Exit
} }
Write-BuildLog " "
If (!(Test-Path "B:\*")) { Net use B: \\nas\Build} If (!(Test-Path "B:\*")) { Net use B: \\nas\Build}
if (Test-Path "B:\Automate\automate.ini") { if (Test-Path "B:\Automate\automate.ini") {
Write-BuildLog "Determining automate.ini settings." Write-BuildLog "Determining automate.ini settings."
@ -91,21 +83,21 @@ if (Test-Path "B:\Automate\automate.ini") {
$createxp = ((Select-String -SimpleMatch "BuildViewVM=" -Path "B:\Automate\automate.ini").line).substring(12).Trim() $createxp = ((Select-String -SimpleMatch "BuildViewVM=" -Path "B:\Automate\automate.ini").line).substring(12).Trim()
if ($createds -like "true") { if ($createds -like "true") {
$createds = $true $createds = $true
Write-BuildLog " Datastores will be built and added to vCenter." Write-BuildLog "Datastores will be built and added to vCenter."
} else { } else {
$createds = $false $createds = $false
} }
if ($createvm -like "true") { if ($createvm -like "true") {
$createvm = $true $createvm = $true
$ProdKey = ((Select-String -SimpleMatch "ProductKey=" -Path "B:\Automate\automate.ini" -List).line).substring(11).Trim() $ProdKey = ((Select-String -SimpleMatch "ProductKey=" -Path "B:\Automate\automate.ini" -List).line).substring(11).Trim()
Write-BuildLog " Windows 2003 VM for Lab will be created." Write-BuildLog "Windows 2003 VM for Lab will be created."
} else { } else {
$createvm = $false $createvm = $false
} }
if ($createxp -like "true") { if ($createxp -like "true") {
$createxp = $true $createxp = $true
$XPKey = ((Select-String -SimpleMatch "ViewVMProductKey=" -Path "B:\Automate\automate.ini").line).substring(17) $XPKey = ((Select-String -SimpleMatch "ViewVMProductKey=" -Path "B:\Automate\automate.ini").line).substring(17)
Write-BuildLog " Windows XP VM for VMware View Lab to be built." Write-BuildLog "Windows XP VM for VMware View Lab to be built."
} else { } else {
$createxp = $false $createxp = $false
} }
@ -196,9 +188,7 @@ for ($i=1;$i -le $MaxHosts; $i++) {
} }
Start-Sleep 5 Start-Sleep 5
While ((Get-VMHost $VMHost).ConnectionState -ne "Connected"){ While ((Get-VMHost $VMHost).ConnectionState -ne "Connected"){
Write-BuildLog " "
Write-BuildLog $VMHost " is not yet connected. Pausing for 5 seconds." Write-BuildLog $VMHost " is not yet connected. Pausing for 5 seconds."
Write-BuildLog " "
Start-Sleep 5 Start-Sleep 5
} }
$VMHostObj = Get-VMHost $VMHost $VMHostObj = Get-VMHost $VMHost
@ -274,7 +264,7 @@ for ($i=1;$i -le $MaxHosts; $i++) {
Write-BuildLog "Restarting all hosts for consistency. This will take a few minutes." Write-BuildLog "Restarting all hosts for consistency. This will take a few minutes."
$null = Get-VMHost -location $ClusterName | Restart-VMHost -confirm:$false -Force $null = Get-VMHost -location $ClusterName | Restart-VMHost -confirm:$false -Force
Write-Host "Wait until all hosts have stopped pinging" Write-BuildLog "Wait until all hosts have stopped pinging"
$PingStatus = @() $PingStatus = @()
for ($i=1;$i -le $MaxHosts; $i++) {$PingStatus +=$True} for ($i=1;$i -le $MaxHosts; $i++) {$PingStatus +=$True}
do { do {
@ -291,7 +281,7 @@ do {
If ($PingStatus[$I-1] -eq $True) {$StayHere = $True} If ($PingStatus[$I-1] -eq $True) {$StayHere = $True}
} }
} while ($StayHere) } while ($StayHere)
Write-Host "Wait until all hosts are pinging" Write-BuildLog "Wait until all hosts are pinging"
do { do {
Start-Sleep -Seconds 1 Start-Sleep -Seconds 1
$ping = new-object System.Net.NetworkInformation.Ping $ping = new-object System.Net.NetworkInformation.Ping
@ -306,7 +296,7 @@ do {
If ($PingStatus[$I-1] -eq $False) {$StayHere = $True} If ($PingStatus[$I-1] -eq $False) {$StayHere = $True}
} }
} while ($StayHere) } while ($StayHere)
Write-Host "Wait until all hosts are Connected" Write-BuildLog "Wait until all hosts are Connected"
for ($i=1;$i -le $MaxHosts; $i++) {$PingStatus +=$False} for ($i=1;$i -le $MaxHosts; $i++) {$PingStatus +=$False}
do { do {
Start-Sleep -Seconds 1 Start-Sleep -Seconds 1
@ -321,7 +311,7 @@ do {
If ($PingStatus[$I-1] -eq $False) {$StayHere = $True} If ($PingStatus[$I-1] -eq $False) {$StayHere = $True}
} }
} while ($StayHere) } while ($StayHere)
Write-Host "Wait 2 minutes so last host is properly up" Write-BuildLog "Wait 2 minutes so last host is properly up"
start-sleep 120 start-sleep 120
If ($SRM -ne $True){ If ($SRM -ne $True){
if (((Get-OSCustomizationSpec | where {$_.Name -eq "Windows"}) -eq $null) -and ($ProdKey -ne $null) ){ if (((Get-OSCustomizationSpec | where {$_.Name -eq "Windows"}) -eq $null) -and ($ProdKey -ne $null) ){
@ -378,131 +368,144 @@ If ($SRM -ne $True){
$Cluster = Get-View $Cluster $Cluster = Get-View $Cluster
$null = $Cluster.ReconfigureComputeResource_Task($spec, $true) $null = $Cluster.ReconfigureComputeResource_Task($spec, $true)
Write-BuildLog "Waiting two minutes for HA to complete configuration." Write-BuildLog "Waiting two minutes for HA to complete configuration."
$Datastore = Get-Datastore -VMhost $vmHost -name "NFS01"
Start-Sleep -Seconds 120 Start-Sleep -Seconds 120
if (!(Get-PSDrive -Name NFS01 -ErrorAction "SilentlyContinue")) {
$null = New-PSDrive -Name NFS01 -PSProvider ViMdatastore -Root '\' -Location $Datastore
}
$VMHostObj = Get-VMHost $VMHost $VMHostObj = Get-VMHost $VMHost
$VMName="Template2012" $HostVer = (([int]((($VMHostObj.Version.Split("."))[0])) *10) + [int]($VMHostObj.Version.Split("."))[1])
if (($CreateVM) -and ((Get-VM -name $VMName -ErrorAction "SilentlyContinue") -eq $null ) -and (test-path "\\192.168.199.7\build\Win2012.ISO")) { foreach ($os in ("2016","2012", "2008", "2K3", "10", "8", "7", "XP")){
$Datastore = Get-Datastore -VMhost $vmHost -name "NFS01" $VMName=("Template" + $OS)
Start-Sleep -Seconds 2 if (($CreateVM) -and ((Get-VM -name $VMName -ErrorAction "SilentlyContinue") -eq $null ) -and (test-path ("\\192.168.199.7\build\Win" + $OS + ".iso"))) {
if (!(Get-PSDrive -Name NFS01 -ErrorAction "SilentlyContinue")) { #Create new VM if existing VM or template doesn't exist
$null = New-PSDrive -Name NFS01 -PSProvider ViMdatastore -Root '\' -Location $Datastore if (!(Test-Path NFS01:\$VMName\$VMName.vmdk)) {
} $Go = $False
#Create new VM if existing VM or template doesn't exist Switch ($OS) {
if (!(Test-Path NFS01:\$VMName\$VMName.vmdk)) { "2016" {
Write-BuildLog "Creating Template2012 VM as Windows Server 2012" $GuestID = "windows9Server64Guest"
If ((Get-vmhost)[0].version -lt "5.5.0"){ $GuestRAM = 768
$MyVM = New-VM -Name $VMName -VMhost $vmHost -datastore $Datastore -NumCPU 1 -MemoryMB 768 -DiskMB 16384 -DiskStorageFormat Thin -GuestID windows8Server64Guest $GuestHDD = 16384
get-networkadapter $MyVM |set-networkadapter -type e1000 -confirm:$false $GuestMinHost = 60
} Else { $GuestMaxHost = 99
$MyVM = New-VM -Name $VMName -VMhost $vmHost -datastore $Datastore -NumCPU 1 -MemoryMB 768 -DiskMB 16384 -DiskStorageFormat Thin -GuestID windows8Server64Guest -Version "v8" if (($HostVer -ge $GuestMinHost) -and ($HostVer -le $GuestMaxHost)) {
} $Go = $True
$null = New-CDDrive -VM $MyVM -ISOPath "[Build] /Win2012.ISO" -StartConnected $VMHWVer = "v11"
$null = New-FloppyDrive -VM $MyVM -FloppyImagePath "[Build] Automate/BootFloppies/Nested2012.flp" -StartConnected }
$strBootHDiskDeviceName = "Hard disk 1" }"2012" {
$viewVM = Get-View -ViewType VirtualMachine -Property Name, Config.Hardware.Device -Filter @{"Name" = "^$VMName$"} $GuestID = "windows8Server64Guest"
## get the VirtualDisk device, then grab its Key (DeviceKey, used later) $GuestRAM = 768
$intHDiskDeviceKey = ($viewVM.Config.Hardware.Device | ?{$_.DeviceInfo.Label -eq $strBootHDiskDeviceName}).Key $GuestHDD = 16384
## bootable Disk BootOption device, for use in setting BootOrder (the corresponding VirtualDisk device is bootable, assumed) $GuestMinHost = 50
$oBootableHDisk = New-Object -TypeName VMware.Vim.VirtualMachineBootOptionsBootableDiskDevice -Property @{"DeviceKey" = $intHDiskDeviceKey} $GuestMaxHost = 99
## bootable CDROM device (per the docs, the first CDROM with bootable media found is used) if (($HostVer -ge $GuestMinHost) -and ($HostVer -le $GuestMaxHost)) {
$oBootableCDRom = New-Object -Type VMware.Vim.VirtualMachineBootOptionsBootableCdromDevice $Go = $True
## create the VirtualMachineConfigSpec with which to change the VM's boot order $VMHWVer = "v8"
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec -Property @{"BootOptions" = New-Object VMware.Vim.VirtualMachineBootOptions -Property @{BootOrder = $oBootableCDRom, $oBootableHDisk}} }
$null = $viewVM.ReconfigVM_Task($spec) } "2008" {
Write-BuildLog "Powering on VM and installing Windows." $GuestID = "windows7Server64Guest"
$null = Start-VM $MyVM $GuestRAM = 768
} else { $GuestHDD = 16384
Write-BuildLog "Found existing WinTemplate." $GuestMinHost = 40
if (Test-Path NFS01:\$VMName\$VMName.vmtx) { $GuestMaxHost = 99
Write-BuildLog "Registering existing Template2012 template." if (($HostVer -ge $GuestMinHost) -and ($HostVer -le $GuestMaxHost)) {
$vmxFile = Get-Item NFS01:\$VMName\$VMName.vmtx $Go = $True
$null = New-Template -VMHost $VMHost -TemplateFilePath $vmxFile.DatastoreFullPath $VMHWVer = "v7"
Write-BuildLog "Existing WinTemplate Template added to inventory." }
} "2K3" {
$GuestID = "winNetStandard64Guest"
$GuestRAM = 384
$GuestHDD = 3072
$GuestMinHost = 30
$GuestMaxHost = 99
if (($HostVer -ge $GuestMinHost) -and ($HostVer -le $GuestMaxHost)) {
$Go = $True
$VMHWVer = "v7"
}
} "10" {
$GuestID = "windows9_64Guest"
$GuestRAM = 768
$GuestHDD = 16384
$GuestMinHost = 60
$GuestMaxHost = 99
if (($HostVer -ge $GuestMinHost) -and ($HostVer -le $GuestMaxHost)) {
$Go = $True
$VMHWVer = "v11"
}
} "8" {
$GuestID = "windows8_64Guest"
$GuestRAM = 768
$GuestHDD = 16384
$GuestMinHost = 50
$GuestMaxHost = 99
if (($HostVer -ge $GuestMinHost) -and ($HostVer -le $GuestMaxHost)) {
$Go = $True
$VMHWVer = "v8"
}
} "7" {
$GuestID = "windows7_64Guest"
$GuestRAM = 768
$GuestHDD = 16384
$GuestMinHost = 40
$GuestMaxHost = 99
if (($HostVer -ge $GuestMinHost) -and ($HostVer -le $GuestMaxHost)) {
$Go = $True
$VMHWVer = "v7"
}
} "XP" {
$GuestID = "winXPProGuest"
$GuestRAM = 384
$GuestHDD = 3072
$GuestMinHost = 30
$GuestMaxHost = 60
if (($HostVer -ge $GuestMinHost) -and ($HostVer -le $GuestMaxHost)) {
$Go = $True
$VMHWVer = "v7"
}
}
}
If ($Go) {
If ((Get-vmhost)[0].version -lt "5.5.0"){
Write-BuildLog "Creating $VMName VM as Windows $OS"
$MyVM = New-VM -Name $VMName -VMhost $vmHost -datastore $Datastore -NumCPU 1 -MemoryMB $GuestRAM -DiskMB $GuestHDD -DiskStorageFormat Thin -GuestID $GuestID
get-networkadapter $MyVM |set-networkadapter -type e1000 -confirm:$false
} Else {
Write-BuildLog "Creating $VMName VM as Windows $OS"
$MyVM = New-VM -Name $VMName -VMhost $vmHost -datastore $Datastore -NumCPU 1 -MemoryMB $GuestRAM -DiskMB $GuestHDD -DiskStorageFormat Thin -GuestID $GuestID -Version $VMHWVer
}
$BuildISO = "[Build]/Auto" + $OS + ".iso"
if (test-path ("\\192.168.199.7\build\Auto" + $OS + ".iso")) {
$null = New-CDDrive -VM $MyVM -ISOPath $BuildISO -StartConnect
} else {
$BuildISO = "[Build]/Win" + $OS + ".iso"
$null = New-CDDrive -VM $MyVM -ISOPath $BuildISO -StartConnected
$null = New-FloppyDrive -VM $MyVM -FloppyImagePath ("[Build] Automate/BootFloppies/Nested" + $OS + ".flp") -StartConnected
}
$strBootHDiskDeviceName = "Hard disk 1"
$viewVM = Get-View -ViewType VirtualMachine -Property Name, Config.Hardware.Device -Filter @{"Name" = "^$VMName$"}
$intHDiskDeviceKey = ($viewVM.Config.Hardware.Device | ?{$_.DeviceInfo.Label -eq $strBootHDiskDeviceName}).Key
$oBootableHDisk = New-Object -TypeName VMware.Vim.VirtualMachineBootOptionsBootableDiskDevice -Property @{"DeviceKey" = $intHDiskDeviceKey}
$oBootableCDRom = New-Object -Type VMware.Vim.VirtualMachineBootOptionsBootableCdromDevice
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec -Property @{"BootOptions" = New-Object VMware.Vim.VirtualMachineBootOptions -Property @{BootOrder = $oBootableCDRom, $oBootableHDisk}}
$null = $viewVM.ReconfigVM_Task($spec)
$null = Start-VM $MyVM
} else {
Write-BuildLog "Not creating Windows $OS VM"
}
} else {
Write-BuildLog "Found existing $VMName."
if (Test-Path NFS01:\$VMName\$VMName.vmtx) {
Write-BuildLog "Registering existing Template$os template."
$vmxFile = Get-Item NFS01:\$VMName\$VMName.vmtx
$null = New-Template -VMHost $VMHost -TemplateFilePath $vmxFile.DatastoreFullPath
Write-BuildLog "Existing $VMName Template added to inventory."
}
} }
Start-Sleep -Seconds 2
} }
Start-Sleep -Seconds 2
$null = Remove-PSDrive NFS01
} }
$null = Remove-PSDrive NFS01
if ($vmhostObj.version.split(".")[0] -eq "4") {
$Datastore = Get-Datastore -VMhost $vmHost -name "iSCSI2"
$VMName="WinTemplate4"
} else {
$Datastore = Get-Datastore -VMhost $vmHost -name "iSCSI1"
$VMName="WinTemplate"
}
if (($CreateVM) -and ((Get-VM -name $VMName -ErrorAction "SilentlyContinue") -eq $null ) -and (test-path "\\192.168.199.7\build\Auto2K3.ISO")) {
if (!(Get-PSDrive -Name iSCSI1 -ErrorAction "SilentlyContinue")) {
$null = New-PSDrive -Name iSCSI1 -PSProvider ViMdatastore -Root '\' -Location $Datastore
}
Start-Sleep -Seconds 2
#Create new VM if existing VM or template doesn't exist
if (!(Test-Path iSCSI1:\$VMName\$VMName.vmdk)) {
Write-BuildLog "Creating WinTemplate VM Windows Server 2003."
If ((Get-vmhost)[0].version -lt "5.5.0"){
$MyVM = New-VM -Name $VMName -VMhost $vmHost -datastore $Datastore -NumCPU 1 -MemoryMB 384 -DiskMB 3072 -DiskStorageFormat Thin -GuestID winNetEnterpriseGuest
} Else {
$MyVM = New-VM -Name $VMName -VMhost $vmHost -datastore $Datastore -NumCPU 1 -MemoryMB 384 -DiskMB 3072 -DiskStorageFormat Thin -GuestID winNetEnterpriseGuest -Version "v8"
}
$null = New-CDDrive -VM $MyVM -ISOPath "[Build] /Auto2K3.iso" -StartConnected
Write-BuildLog "Powering on VM and installing Windows."
$null = Start-VM $MyVM
} else {
Write-BuildLog "Found existing WinTemplate."
if (Test-Path iSCSI1:\$VMName\$VMName.vmtx) {
Write-BuildLog "Registering existing WinTemplate template."
$vmxFile = Get-Item iSCSI1:\$VMName\$VMName.vmtx
$null = New-Template -VMHost $VMHost -TemplateFilePath $vmxFile.DatastoreFullPath
Write-BuildLog "Existing WinTemplate Template added to inventory."
}
}
Start-Sleep -Seconds 2
$null = Remove-PSDrive iSCSI1
}
$VMName = "WinXP"
$Datastore = Get-Datastore "iSCSI2"
if (($CreateXP) -and ((Get-VM -name $VMName -ErrorAction "SilentlyContinue") -eq $null ) -and (test-path "\\192.168.199.7\build\AutoXP.iso")) {
if (!(Get-PSDrive -Name iSCSI2 -ErrorAction "SilentlyContinue")) {
$null = New-PSDrive -Name iSCSI2 -PSProvider ViMdatastore -Root '\' -Location $Datastore
}
Start-Sleep -Seconds 2
#Create new VM if existing VM or template doesn't exist
if (!(Test-Path iSCSI2:\$VMName\$VMName.vmdk)) {
Write-BuildLog "Creating Windows XP VM for View."
If ((Get-vmhost)[0].version -lt "5.5.0"){
$MyVM = New-VM -Name $VMName -VMhost $vmHost -datastore $Datastore -NumCPU 1 -MemoryMB 384 -GuestID winXPProGuest
} Else {
$MyVM = New-VM -Name $VMName -VMhost $vmHost -datastore $Datastore -NumCPU 1 -MemoryMB 384 -GuestID winXPProGuest -Version "v8"
}
$null = New-CDDrive -VM $MyVM -ISOPath "[Build] /AutoXP.iso" -StartConnected
$null = New-FloppyDrive -VM $MyVM -FloppyImagePath "[Build] Automate/BootFloppies/vmscsi-1.2.0.4.flp" -StartConnected
$strBootHDiskDeviceName = "Hard disk 1"
$viewVM = Get-View -ViewType VirtualMachine -Property Name, Config.Hardware.Device -Filter @{"Name" = "^$VMName$"}
## get the VirtualDisk device, then grab its Key (DeviceKey, used later)
$intHDiskDeviceKey = ($viewVM.Config.Hardware.Device | ?{$_.DeviceInfo.Label -eq $strBootHDiskDeviceName}).Key
## bootable Disk BootOption device, for use in setting BootOrder (the corresponding VirtualDisk device is bootable, assumed)
$oBootableHDisk = New-Object -TypeName VMware.Vim.VirtualMachineBootOptionsBootableDiskDevice -Property @{"DeviceKey" = $intHDiskDeviceKey}
## bootable CDROM device (per the docs, the first CDROM with bootable media found is used)
$oBootableCDRom = New-Object -Type VMware.Vim.VirtualMachineBootOptionsBootableCdromDevice
## create the VirtualMachineConfigSpec with which to change the VM's boot order
$spec = New-Object VMware.Vim.VirtualMachineConfigSpec -Property @{"BootOptions" = New-Object VMware.Vim.VirtualMachineBootOptions -Property @{BootOrder = $oBootableCDRom, $oBootableHDisk}}
$null = $viewVM.ReconfigVM_Task($spec)
$Null = Start-VM $MyVM
} else {
Write-BuildLog "Found existing WinXP."
if (Test-Path iSCSI1:\$VMName\$VMName.vmtx) {
Write-BuildLog "Registering existing WinTemplate template."
$vmxFile = Get-Item iSCSI2:\$VMName\$VMName.vmtx
$null = New-Template -VMHost $VMHost -TemplateFilePath $vmxFile.DatastoreFullPath
Write-BuildLog "Existing WinTemplate Template added to inventory."
}
}
Start-Sleep -Seconds 2
$null = Remove-PSDrive iSCSI2
}
$VMName = "TTYLinux" $VMName = "TTYLinux"
if ((Get-VM -name $VMName -ErrorAction "SilentlyContinue") -eq $null ) { if ((Get-VM -name $VMName -ErrorAction "SilentlyContinue") -eq $null ) {
Write-BuildLog "Registering existing tiny TTYLinux VM." Write-BuildLog "Registering existing tiny TTYLinux VM."
@ -526,10 +529,6 @@ If ($SRM -ne $True){
$null = Remove-PSDrive iSCSI3 $null = Remove-PSDrive iSCSI3
} }
} }
Write-BuildLog " "
$null = Disconnect-VIServer -Server * -confirm:$false $null = Disconnect-VIServer -Server * -confirm:$false
if (Test-Path "C:\Program Files\VMware\VMware Tools\VMwareToolboxCmd.exe") { #Read-Host " All OK?"
Read-Host " Configuration complete, press <Enter> to continue."
}
exit

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -1,10 +1,10 @@
@echo off @echo off
echo ************************* echo *************************
echo * echo * Begining Build.cmd as %userdomain%\%username%
echo ** echo * Begining Build.cmd as %userdomain%\%username% >> c:\buildlog.txt
echo * Connect to build share echo * Connect to build share
net use B: \\192.168.199.7\Build >> c:\buildlog.txt if not exist B:\ net use B: \\192.168.199.7\Build
type b:\automate\version.txt >> c:\buildlog.txt if not exist c:\temp\ md c:\temp
regedit -s b:\Automate\_Common\ExecuPol.reg regedit -s b:\Automate\_Common\ExecuPol.reg
regedit -s b:\Automate\_Common\NoSCRNSave.reg regedit -s b:\Automate\_Common\NoSCRNSave.reg
regedit -s B:\Automate\_Common\ExplorerView.reg regedit -s B:\Automate\_Common\ExplorerView.reg
@ -13,11 +13,13 @@ regedit -s b:\Automate\_Common\Nested.reg
REG ADD "HKCU\Environment" /V SEE_MASK_NOZONECHECKS /T REG_SZ /D 1 /F REG ADD "HKCU\Environment" /V SEE_MASK_NOZONECHECKS /T REG_SZ /D 1 /F
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V SEE_MASK_NOZONECHECKS /T REG_SZ /D 1 /F REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V SEE_MASK_NOZONECHECKS /T REG_SZ /D 1 /F
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments " /V SaveZoneInformation /T REG_DWORD /D 1 /F REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments " /V SaveZoneInformation /T REG_DWORD /D 1 /F
copy B:\automate\_Common\wasp.dll C:\windows\system32
echo * Activate Windows >> c:\buildlog.txt echo * Activate Windows >> c:\buildlog.txt
cscript //B "%windir%\system32\slmgr.vbs" /ato cscript //B "%windir%\system32\slmgr.vbs" /ato
copy B:\Automate\PSFunctions.ps1 C:\ copy B:\Automate\PSFunctions.ps1 C:\
copy B:\Automate\validate.ps1 C:\
copy B:\Automate\ViewSetup.ps1 C:\
copy B:\Automate\%computername%\Build.ps1 c:\ copy B:\Automate\%computername%\Build.ps1 c:\
echo * Starting PowerShell script for Phase 2 completion echo * Starting PowerShell script for Phase 2 completion
echo * Starting PowerShell script for Phase 2 completion >> C:\buildlog.txt echo * Starting PowerShell script for Phase 2 completion >> C:\buildlog.txt
powershell c:\Build.ps1 powershell c:\Build.ps1
if exist C:\Build.ps1 del c:\Build.ps1

View File

@ -6,30 +6,56 @@ if (Test-Path C:\PSFunctions.ps1) {
exit exit
} }
$a = (Get-Host).UI.RawUI
$a.WindowTitle = "CS1 Build Automation"
$b = $a.WindowSize
$b.Height = $a.MaxWindowSize.Height - 1
$a.WindowSize = $b
Import-Module C:\windows\system32\WASP.dll
Select-Window -Title "CS1 Build Automation" | set-windowposition -left 75 -top 3
if (Test-Path "B:\Automate\automate.ini") { if (Test-Path "B:\Automate\automate.ini") {
Write-BuildLog "Determining automate.ini settings." Write-BuildLog "Determining automate.ini settings."
$viewinstall = ((Select-String -SimpleMatch "ViewInstall=" -Path "B:\Automate\automate.ini").line).substring(12) $viewinstall = ((Select-String -SimpleMatch "ViewInstall=" -Path "B:\Automate\automate.ini").line).substring(12)
Write-BuildLog " VMware View install set to $viewinstall." Write-BuildLog " VMware View install set to $viewinstall."
$timezone = ((Select-String -SimpleMatch "TZ=" -Path "B:\Automate\automate.ini").line).substring(3) $timezone = ((Select-String -SimpleMatch "TZ=" -Path "B:\Automate\automate.ini").line).substring(3)
Write-BuildLog " Timezone set to $timezone." Write-BuildLog "Timezone set to $timezone."
tzutil /s "$timezone" tzutil /s "$timezone"
$AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9) $AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9)
$emailto = ((Select-String -SimpleMatch "emailto=" -Path "B:\Automate\automate.ini").line).substring(8) $emailto = ((Select-String -SimpleMatch "emailto=" -Path "B:\Automate\automate.ini").line).substring(8)
$SmtpServer = ((Select-String -SimpleMatch "SmtpServer=" -Path "B:\Automate\automate.ini").line).substring(11) $SmtpServer = ((Select-String -SimpleMatch "SmtpServer=" -Path "B:\Automate\automate.ini").line).substring(11)
} }
If (([System.Environment]::OSVersion.Version.Major -eq 6) -and ([System.Environment]::OSVersion.Version.Minor -ge 2)) { if ((Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain -eq $False) {
Write-BuildLog "Joining domain"
B:\automate\_Common\Autologon administrator lab $AdminPWD
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f
$password = $AdminPWD | ConvertTo-SecureString -asPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential("administrator",$password)
$null = Add-Computer -DomainName "lab.local" -Credential $credential -restart
read-host "Wait for restart"
} else {
regedit /s b:\Automate\_Common\ExecuPol.reg
regedit -s b:\Automate\_Common\NoSCRNSave.reg
Write-BuildLog "Change default local administrator password"
net user administrator $AdminPWD
B:\automate\_Common\Autologon administrator lab $AdminPWD
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f
}
If ((([System.Environment]::OSVersion.Version.Major *10) + [System.Environment]::OSVersion.Version.Minor) -ge 62) {
Write-BuildLog "Disabling autorun of ServerManager at logon." Write-BuildLog "Disabling autorun of ServerManager at logon."
Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs
Write-BuildLog "Disabling screen saver" Write-BuildLog "Disabling screen saver"
set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0 set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0
Write-BuildLog "Install admin tools" Write-BuildLog "Install admin tools"
Add-WindowsFeature RSAT-Feature-Tools,RSAT-DHCP,RSAT-DNS-Server,RSAT-AD-AdminCenter Add-WindowsFeature RSAT-Feature-Tools,RSAT-DHCP,RSAT-DNS-Server,RSAT-AD-AdminCenter
Write-BuildLog "Enable remote management through firewall" Write-BuildLog "Setup Firewall"
Netsh firewall set service RemoteAdmin netsh advfirewall firewall add rule name="All ICMP V4" dir=in action=allow protocol=icmpv4
Netsh advfirewall set currentprofile settings remotemanagement enable netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
} }
do {
start-sleep 10
} until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null)
$Files = get-childitem "b:\view$viewinstall" $Files = get-childitem "b:\view$viewinstall"
for ($i=0; $i -lt $files.Count; $i++) { for ($i=0; $i -lt $files.Count; $i++) {
If ($Files[$i].Name -like "VMware-viewconnectionserver*") {$Installer = $Files[$i].FullName} If ($Files[$i].Name -like "VMware-viewconnectionserver*") {$Installer = $Files[$i].FullName}
@ -38,68 +64,82 @@ Switch ($ViewInstall) {
50 { 50 {
Write-BuildLog "Install View 5.0 Connection Server" Write-BuildLog "Install View 5.0 Connection Server"
Start-Process $Installer -wait -ArgumentList " /s /v'/qn VDM_SERVER_INSTANCE_TYPE=1'" Start-Process $Installer -wait -ArgumentList " /s /v'/qn VDM_SERVER_INSTANCE_TYPE=1'"
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" >> c:\buildLog.txt C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
copy b:\automate\ViewSetup.ps1 c:\
start-sleep 60
%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe c:\ViewSetup.ps1 >> c:\buildlog.txt
} }
51 { 51 {
Write-BuildLog "Install View 5.1 Connection Server" Write-BuildLog "Install View 5.1 Connection Server"
Start-Process $Installer -wait -ArgumentList '/s /v"/qb VDM_SERVER_INSTANCE_TYPE=1 VDM_SERVER_RECOVERY_PWD=VMware1! VDM_SERVER_RECOVERY_PWD2=VMware1! VDM_INITIAL_ADMIN_OPTION=1 CEIP_OPTIN=0"' Start-Process $Installer -wait -ArgumentList '/s /v"/qb VDM_SERVER_INSTANCE_TYPE=1 VDM_SERVER_RECOVERY_PWD=VMware1! VDM_SERVER_RECOVERY_PWD2=VMware1! VDM_INITIAL_ADMIN_OPTION=1 CEIP_OPTIN=0"'
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" >> c:\buildLog.txt C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
} }
52 { 52 {
Write-BuildLog "Install View 5.2 Connection Server" Write-BuildLog "Install View 5.2 Connection Server"
Start-Process $Installer -wait -ArgumentList '/s /v"/qb VDM_SERVER_INSTANCE_TYPE=1 VDM_SERVER_RECOVERY_PWD=VMware1! VDM_SERVER_RECOVERY_PWD2=VMware1! VDM_INITIAL_ADMIN_OPTION=1 CEIP_OPTIN=0"' Start-Process $Installer -wait -ArgumentList '/s /v"/qb VDM_SERVER_INSTANCE_TYPE=1 VDM_SERVER_RECOVERY_PWD=VMware1! VDM_SERVER_RECOVERY_PWD2=VMware1! VDM_INITIAL_ADMIN_OPTION=1 CEIP_OPTIN=0"'
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" >> c:\buildLog.txt C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
} }
53 { 53 {
Write-BuildLog "Install View 5.3 Connection Server" Write-BuildLog "Install View 5.3 Connection Server"
Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=1 VDM_SERVER_RECOVERY_PWD=VMware1! VDM_SERVER_RECOVERY_PWD2=VMware1! VDM_INITIAL_ADMIN_OPTION=1 CEIP_OPTIN=0"' Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=1 VDM_SERVER_RECOVERY_PWD=VMware1! VDM_SERVER_RECOVERY_PWD2=VMware1! VDM_INITIAL_ADMIN_OPTION=1 CEIP_OPTIN=0"'
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" >> c:\buildLog.txt C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
} }
60 { 60 {
Write-BuildLog "Install View 6.0 Connection Server" Write-BuildLog "Install View 6.0 Connection Server"
copy $Installer C:\ViewInstaller.exe copy $Installer C:\ViewInstaller.exe
Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=1 FWCHOICE=1 VDM_INITIAL_ADMIN_SID=S-1-5-32-544 VDM_SERVER_RECOVERY_PWD=VMware1 VDM_SERVER_RECOVERY_PWD_REMINDER=First"' Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=1 FWCHOICE=1 VDM_INITIAL_ADMIN_SID=S-1-5-32-544 VDM_SERVER_RECOVERY_PWD=VMware1 VDM_SERVER_RECOVERY_PWD_REMINDER=First"'
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" >> c:\buildLog.txt if (([System.Environment]::OSVersion.Version.Major -eq 6) -and ([System.Environment]::OSVersion.Version.Minor -ge 3)) {
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
}else {
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
}
} }
70 { 70 {
Write-BuildLog "Install View 7.0 Connection Server" Write-BuildLog "Install View 7.0 Connection Server"
copy $Installer C:\ViewInstaller.exe copy $Installer C:\ViewInstaller.exe
Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=1 FWCHOICE=1 VDM_INITIAL_ADMIN_SID=S-1-5-32-544 VDM_SERVER_RECOVERY_PWD=VMware1 VDM_SERVER_RECOVERY_PWD_REMINDER=First"' Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=1 FWCHOICE=1 VDM_INITIAL_ADMIN_SID=S-1-5-32-544 VDM_SERVER_RECOVERY_PWD=VMware1 VDM_SERVER_RECOVERY_PWD_REMINDER=First"'
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" >> c:\buildLog.txt if ([System.Environment]::OSVersion.Version.Major -ge 9) {
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
}else {
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
}
} 75 {
Write-BuildLog "Install View 7.5 Connection Server"
copy $Installer C:\ViewInstaller.exe
Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/v"/qb VDM_SERVER_INSTANCE_TYPE=1 FWCHOICE=1 VDM_INITIAL_ADMIN_SID=S-1-5-32-544 VDM_SERVER_RECOVERY_PWD=VMware1 VDM_SERVER_RECOVERY_PWD_REMINDER=First VDM_IP_PROTOCOL_USAG=IPv4 HTMLACCESS=1"'
if ([System.Environment]::OSVersion.Version.Major -ge 9) {
C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
}else {
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
}
}
}
browserAndFlash
$PCLIver = deployPowerCLI
if (($PCLIver -ge 65) -and ($viewinstall -ge 70) -and ([System.Environment]::OSVersion.Version.Major -ge 10)){
copy-item -path b:\automate\cs1\ConfigView.ps1 -destination c:\
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Config /t REG_SZ /d 'powershell.exe c:\ConfigView.ps1' /f
} else {
start-process powershell.exe -ArgumentList " C:\viewsetup.ps1" -redirectstandardoutput "C:\ViewLog.txt" -Wait
Get-Content "C:\ViewLog.txt" | Out-File "C:\BuildLog.txt" -Append
if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none")){
Write-BuildLog "Emailing log"
$mailmessage = New-Object system.net.mail.mailmessage
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$mailmessage.from = "AutoLab<autolab@labguides.com>"
$mailmessage.To.add($emailto)
$Summary = "Completed AutoLab VM build.`r`n"
$Summary += "The build of $env:computername has finished, installing VMware Tools and rebooting`r`n"
$Summary += "The build log is attached`r`n"
$mailmessage.Subject = "$env:computername VM build finished"
$mailmessage.Body = $Summary
$attach = new-object Net.Mail.Attachment("C:\buildlog.txt")
$mailmessage.Attachments.Add($attach)
$SMTPClient.Send($mailmessage)
$mailmessage.dispose()
$SMTPClient.dispose()
} }
} }
Write-BuildLog "Install Flash Player"
Start-Process msiexec -wait -ArgumentList " /i b:\Automate\_Common\install_flash_player_11_active_x.msi /qn"
Write-BuildLog "Setup Firewall"
netsh advfirewall firewall add rule name="All ICMP V4" dir=in action=allow protocol=icmpv4
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
Write-BuildLog "Setup persistet route to other subnet for SRM and View"
route add 192.168.201.0 mask 255.255.255.0 192.168.199.254 -p
Write-BuildLog "Cleanup" Write-BuildLog "Cleanup"
regedit /s b:\Automate\_Common\ExecuPol.reg
regedit -s b:\Automate\_Common\NoSCRNSave.reg
Write-BuildLog "Change default local administrator password"
net user administrator $AdminPWD
B:\automate\_Common\Autologon vi-admin lab $AdminPWD
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f
Write-BuildLog "Install VMware Tools" Write-BuildLog "Install VMware Tools"
b:\VMTools\Setup64.exe /s /v "/qn" b:\VMTools\Setup64.exe /s /v "/qn"
if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none")){
$mailmessage = New-Object system.net.mail.mailmessage
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$mailmessage.from = "AutoLab<autolab@labguides.com>"
$mailmessage.To.add($emailto)
$Summary = "Completed AutoLab VM build.`r`n"
$Summary += "The build of $env:computername has finished, installing VMware Tools and rebooting`r`n"
$Summary += "The build log is attached`r`n"
$mailmessage.Subject = "$env:computername VM build finished"
$mailmessage.Body = $Summary
$attach = new-object Net.Mail.Attachment("C:\buildlog.txt")
$mailmessage.Attachments.Add($attach)
$SMTPClient.Send($mailmessage)
}
Read-Host "Rebooting after VMTools Install" Read-Host "Rebooting after VMTools Install"

View File

@ -0,0 +1,156 @@
If (-Not(Test-Path -path "b:\")) { net use B: \\192.168.199.7\Build}
. "C:\PSFunctions.ps1"
$userID = "vi-admin@lab.local"
$VCHost = 'vc.lab.local'
$url = 'https://' + $VCHost
$AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9)
$secpasswd = ConvertTo-SecureString $AdminPWD -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential ($userID, $secpasswd)
$emailto = ((Select-String -SimpleMatch "emailto=" -Path "B:\Automate\automate.ini").line).substring(8)
$SmtpServer = ((Select-String -SimpleMatch "SmtpServer=" -Path "B:\Automate\automate.ini").line).substring(11)
write-BuildLog "Make sure there are no installs underway"
do {
start-sleep 10
} until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null)
write-BuildLog "Waiting two minutes for View services to settle"
Write-Host "You can start building CS2 at this stage"
start-sleep 120
function Get-MapEntry {
param([Parameter(Mandatory = $true)] $Key, [Parameter(Mandatory = $true)] $Value)
$update = New-Object VMware.Hv.MapEntry
$update.key = $key
$update.value = $value
return $update
}
# This script part modified from https://www.sddcmaster.com/2018/02/horizon-view-automation-with-powershell.html
Write-BuildLog "Add VC certificates to local certificate stores"
[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
[System.Uri] $u = New-Object System.Uri($url)
[Net.ServicePoint] $sp = [Net.ServicePointManager]::FindServicePoint($u);
[System.Guid] $groupName = [System.Guid]::NewGuid()
[Net.HttpWebRequest] $req = [Net.WebRequest]::create($url)
$req.Method = "GET"
$req.Timeout = 600000 # = 10 minutes
$req.ConnectionGroupName = $groupName
[Net.HttpWebResponse] $result = $req.GetResponse()
$null = $sp.CloseConnectionGroup($groupName)
$outfilename = "Export.cer"
[System.Byte[]] $data = $sp.Certificate.Export([System.Security.Cryptography.X509Certificates.X509ContentType]::Cert)
[System.IO.File]::WriteAllBytes($outfilename, $data)
$null = Import-Certificate -FilePath "Export.cer" -CertStoreLocation Cert:\LocalMachine\Root
$null = Import-Certificate -FilePath "Export.cer" -CertStoreLocation Cert:\LocalMachine\CA
$null = Import-Certificate -FilePath "Export.cer" -CertStoreLocation Cert:\LocalMachine\My
$null = Import-Certificate -FilePath "Export.cer" -CertStoreLocation Cert:\LocalMachine\AuthRoot
$null = Import-Certificate -FilePath "Export.cer" -CertStoreLocation Cert:\LocalMachine\TrustedDevices
Write-BuildLog "Connect to View"
Import-Module VMware.VimAutomation.HorizonView
$hvServer = Connect-HVServer -server localhost -credential $cred
$Global:hvServices = $hvServer.ExtensionData
Write-BuildLog "Add vCentre to View"
$vcService = New-Object VMware.Hv.VirtualCenterService
$certService = New-Object VMware.Hv.CertificateService
$vcSpecHelper = $vcService.getVirtualCenterSpecHelper()
$serverSpec = $vcSpecHelper.getDataObject().serverSpec
$serverSpec.serverName = $VCHost
$serverSpec.port = 443
$serverSpec.useSSL = $true
$serverSpec.userName = "administrator"
$vcPassword = New-Object VMware.Hv.SecureString
$enc = [system.Text.Encoding]::UTF8
$vcPassword.Utf8String = $enc.GetBytes($AdminPWD)
$serverSpec.password = $vcPassword
$serverSpec.serverType = $certService.getServerSpecHelper().SERVER_TYPE_VIRTUAL_CENTER
$certData = $certService.Certificate_Validate($hvServices, $serverSpec)
$certificateOverride = New-Object VMware.Hv.CertificateThumbprint
$certificateOverride.sslCertThumbprint = $certData.thumbprint.sslCertThumbprint
$certificateOverride.sslCertThumbprintAlgorithm = $certData.thumbprint.sslCertThumbprintAlgorithm
# Adding View Composer was a pain
$ViewComposerData = New-Object VMware.Hv.VirtualCenterViewComposerData
$ViewComposerData.viewComposerType = "LOCAL_TO_VC"
$ViewCompserverspec = New-Object VMware.Hv.ServerSpec
$ViewCompserverspec.port = 18443
$ViewCompserverspec.serverName = 'vc.lab.local'
$ViewCompserverspec.userName = 'administrator'
$ViewCompserverspec.password = $vcPassword
$ViewCompserverspec.serverType = 'VIEW_COMPOSER'
$ViewCompserverspec.useSSL = $True
$ViewComposerData.ServerSpec = $ViewCompserverspec
$compCertService = New-Object VMware.Hv.CertificateService
$compCertData = $compcertService.Certificate_Validate($hvServices, $ViewCompserverspec)
$compCertificateOverride = New-Object VMware.Hv.CertificateThumbprint
$compCertificateOverride.sslCertThumbprint = $compCertData.thumbprint.sslCertThumbprint
$compCertificateOverride.sslCertThumbprintAlgorithm = $compCertData.thumbprint.sslCertThumbprintAlgorithm
$ViewComposerData.CertificateOverride = $compCertificateOverride
$vcSpecHelper.getDataObject().ViewComposerData = $ViewComposerData
$vcSpecHelper.getDataObject().CertificateOverride = $certificateOverride
$vcId = $vcService.VirtualCenter_Create($hvServices, $vcSpecHelper.getDataObject())
Write-BuildLog "Setup View composer domain"
$spec = New-Object VMware.Hv.ViewComposerDomainAdministratorSpec
$spec.Base = New-Object VMware.Hv.ViewComposerDomainAdministratorBase
$spec.Base.Domain = 'lab.local'
$spec.Base.UserName = 'vi-admin'
$ADPassword = New-Object VMware.Hv.SecureString
$ADPassword.Utf8String = $enc.GetBytes("VMware1!")
$spec.Base.Password = $ADPassword
$spec.VirtualCenter = $global:DefaultVIServer.Id
#Write-BuildLog "Set Security Server pairing password"
#Since the type doesn't appear to be in the Powershell module we cannot add the pairing password
#$pairingData = New-Object VMware.Hv.SecurityServerPairingData
#$pairingPassword = New-Object VMware.Hv.SecureString
#$pairingPassword.Utf8String = $enc.GetBytes("VMware1!")
#$pairingData.pairingPassword = $pairingPassword
#$pairingData.timeoutMinutes = 1440
#$CS1 = ($hvServices.ConnectionServer.ConnectionServer_List())[0]
#$CS1.securityServerPairing = $pairingData
$icausername="vi-admin"
$icadomain = "lab.local"
$icadminPassword = New-Object VMware.Hv.SecureString
$enc = [system.Text.Encoding]::UTF8
$icadminPassword.Utf8String = $enc.GetBytes($AdminPWD)
$spec=new-object vmware.hv.InstantCloneEngineDomainAdministratorSpec
$spec.base=new-object vmware.hv.InstantCloneEngineDomainAdministratorBase
$spec.base.domain=(($hvServices.ADDomain.addomain_list() | where {$_.DnsName -eq $icadomain} | select-object -first 1).id)
$spec.base.username=$icausername
$spec.base.password=$icadminpassword
$ICADM = $hvServices.InstantCloneEngineDomainAdministrator.InstantCloneEngineDomainAdministrator_Create($spec)
Write-BuildLog "Setup View eventlog"
$updates = @()
$updates += Get-MapEntry -key "database.server" -value "dc.lab.local"
$updates += Get-MapEntry -key "database.type" -value "SQLSERVER"
$updates += Get-MapEntry -key "database.name" -value "ViewEvents"
$updates += Get-MapEntry -key "database.port" -value 1433
$updates += Get-MapEntry -key "database.userName" -value "VMview"
$updates += Get-MapEntry -key "database.password" -value $ADPassword
$updates += Get-MapEntry -key "database.tablePrefix" -value "Lab_"
$Events = $hvServices.EventDatabase.EventDatabase_Update($updates)
Disconnect-HVServer -server localhost -Force -Confirm:$false
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Config /f
if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none")){
Write-BuildLog "Emailing log"
$mailmessage = New-Object system.net.mail.mailmessage
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$mailmessage.from = "AutoLab<autolab@labguides.com>"
$mailmessage.To.add($emailto)
$Summary = "Completed AutoLab VM build.`r`n"
$Summary += "The build of $env:computername has finished, installing VMware Tools and rebooting`r`n"
$Summary += "The build log is attached`r`n"
$mailmessage.Subject = "$env:computername VM build finished"
$mailmessage.Body = $Summary
$attach = new-object Net.Mail.Attachment("C:\buildlog.txt")
$mailmessage.Attachments.Add($attach)
$SMTPClient.Send($mailmessage)
$mailmessage.dispose()
$SMTPClient.dispose()
}
#read-host "Check VC was added"

View File

@ -1,10 +1,12 @@
@echo off @echo off
echo ************************* echo *************************
echo * echo *
echo ** echo * Begining Build.cmd as %userdomain%\%username%
echo * Begining Build.cmd as %userdomain%\%username% >> c:\buildlog.txt
echo * Connect to build share echo * Connect to build share
net use B: \\192.168.199.7\Build >> c:\buildlog.txt echo * Connect to build share >> c:\buildlog.txt
type b:\automate\version.txt >> c:\buildlog.txt if not exist B:\ net use B: \\192.168.199.7\Build
if not exist c:\temp\ md c:\temp
regedit -s b:\Automate\_Common\ExecuPol.reg regedit -s b:\Automate\_Common\ExecuPol.reg
regedit -s b:\Automate\_Common\NoSCRNSave.reg regedit -s b:\Automate\_Common\NoSCRNSave.reg
regedit -s B:\Automate\_Common\ExplorerView.reg regedit -s B:\Automate\_Common\ExplorerView.reg
@ -13,7 +15,9 @@ REG ADD "HKCU\Environment" /V SEE_MASK_NOZONECHECKS /T REG_SZ /D 1 /F
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V SEE_MASK_NOZONECHECKS /T REG_SZ /D 1 /F REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V SEE_MASK_NOZONECHECKS /T REG_SZ /D 1 /F
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments " /V SaveZoneInformation /T REG_DWORD /D 1 /F REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments " /V SaveZoneInformation /T REG_DWORD /D 1 /F
echo * Activate Windows >> c:\buildlog.txt echo * Activate Windows >> c:\buildlog.txt
copy B:\automate\_Common\wasp.dll C:\windows\system32
cscript //B "%windir%\system32\slmgr.vbs" /ato cscript //B "%windir%\system32\slmgr.vbs" /ato
copy B:\Automate\validate.ps1 C:\
copy B:\Automate\PSFunctions.ps1 C:\ copy B:\Automate\PSFunctions.ps1 C:\
copy B:\Automate\%computername%\Build.ps1 c:\ copy B:\Automate\%computername%\Build.ps1 c:\
echo * Starting PowerShell script for Phase 2 completion echo * Starting PowerShell script for Phase 2 completion

View File

@ -5,6 +5,13 @@ if (Test-Path C:\PSFunctions.ps1) {
Read-Host "Press <Enter> to exit" Read-Host "Press <Enter> to exit"
exit exit
} }
$a = (Get-Host).UI.RawUI
$a.WindowTitle = "CS2 Build Automation"
$b = $a.WindowSize
$b.Height = $a.MaxWindowSize.Height - 1
$a.WindowSize = $b
Import-Module C:\windows\system32\WASP.dll
Select-Window -Title "CS2 Build Automation" | set-windowposition -left 75 -top 3
if (Test-Path "B:\Automate\automate.ini") { if (Test-Path "B:\Automate\automate.ini") {
Write-BuildLog "Determining automate.ini settings." Write-BuildLog "Determining automate.ini settings."
@ -17,13 +24,29 @@ if (Test-Path "B:\Automate\automate.ini") {
$emailto = ((Select-String -SimpleMatch "emailto=" -Path "B:\Automate\automate.ini").line).substring(8) $emailto = ((Select-String -SimpleMatch "emailto=" -Path "B:\Automate\automate.ini").line).substring(8)
$SmtpServer = ((Select-String -SimpleMatch "SmtpServer=" -Path "B:\Automate\automate.ini").line).substring(11) $SmtpServer = ((Select-String -SimpleMatch "SmtpServer=" -Path "B:\Automate\automate.ini").line).substring(11)
} }
If (([System.Environment]::OSVersion.Version.Major -eq 6) -and ([System.Environment]::OSVersion.Version.Minor -ge 2)) { if ((Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain -eq $False) {
Write-BuildLog "Joining domain"
B:\automate\_Common\Autologon administrator lab $AdminPWD
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f
$password = $AdminPWD | ConvertTo-SecureString -asPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential("administrator",$password)
$null = Add-Computer -DomainName "lab.local" -Credential $credential -restart
read-host "Wait for restart"
} else {
regedit /s b:\Automate\_Common\ExecuPol.reg
regedit -s b:\Automate\_Common\NoSCRNSave.reg
Write-BuildLog "Change default local administrator password"
net user administrator $AdminPWD
B:\automate\_Common\Autologon administrator lab $AdminPWD
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f
}
If ((([System.Environment]::OSVersion.Version.Major *10) + [System.Environment]::OSVersion.Version.Minor) -ge 62) {
Write-BuildLog "Disabling autorun of ServerManager at logon." Write-BuildLog "Disabling autorun of ServerManager at logon."
Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs
Write-BuildLog "Disabling screen saver" Write-BuildLog "Disabling screen saver"
set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0 set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0
Write-BuildLog "Install admin tools" Write-BuildLog "Install admin tools"
Add-WindowsFeature RSAT-Feature-Tools,RSAT-DHCP,RSAT-DNS-Server,RSAT-AD-AdminCenter $null = Add-WindowsFeature RSAT-Feature-Tools,RSAT-DHCP,RSAT-DNS-Server,RSAT-AD-AdminCenter
Write-BuildLog "Enable remote management through firewall" Write-BuildLog "Enable remote management through firewall"
Netsh firewall set service RemoteAdmin Netsh firewall set service RemoteAdmin
Netsh advfirewall set currentprofile settings remotemanagement enable Netsh advfirewall set currentprofile settings remotemanagement enable
@ -35,42 +58,70 @@ if (Test-Path "C:\VMware-view*") {
If ($Files[$i].Name -like "VMware-view*") {$Installer = $Files[$i].FullName} If ($Files[$i].Name -like "VMware-view*") {$Installer = $Files[$i].FullName}
} }
switch ($viewinstall) { switch ($viewinstall) {
70 { 75 {
Write-BuildLog "Install View 7.5 Connection Server"
Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local VDM_IP_PROTOCOL_USAG=IPv4 HTMLACCESS=1"' -verb RunAs
if ([System.Environment]::OSVersion.Version.Major -ge 9) {
C:\Windows\Microsoft.NET\Framework64\v4.0.30319 \InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
}else {
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
}
} 70 {
Write-BuildLog "Install View 7.0 Connection Server" Write-BuildLog "Install View 7.0 Connection Server"
Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local"' -verb RunAs Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local"' -verb RunAs
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" >> c:\buildLog.txt if ([System.Environment]::OSVersion.Version.Major -ge 9) {
C:\Windows\Microsoft.NET\Framework64\v4.0.30319 \InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
}else {
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
}
} }
60 { 60 {
Write-BuildLog "Install View 6.0 Connection Server" Write-BuildLog "Install View 6.0 Connection Server"
Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local"' Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local"'
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" >> c:\buildLog.txt C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
} }
53{ 53{
Write-BuildLog "Install View 5.3 Connection Server" Write-BuildLog "Install View 5.3 Connection Server"
Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local"' Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local"'
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" >> c:\buildLog.txt C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
} }
52 { 52 {
Write-BuildLog "Install View 5.2 Connection Server" Write-BuildLog "Install View 5.2 Connection Server"
Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local"' Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local"'
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" >> c:\buildLog.txt C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
} }
51 { 51 {
Write-BuildLog "Install View 5.1 Connection Server" Write-BuildLog "Install View 5.1 Connection Server"
Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local"' Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local"'
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" >> c:\buildLog.txt C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
} }
50 { 50 {
Write-BuildLog "Install View 5.0 Connection Server" Write-BuildLog "Install View 5.0 Connection Server"
Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local"' Start-Process $Installer -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=2 ADAM_PRIMARY_NAME=cs1.lab.local"'
C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" >> c:\buildLog.txt C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll"
} }
} }
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f
if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none")){
Write-BuildLog "Emailing log"
$mailmessage = New-Object system.net.mail.mailmessage
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$mailmessage.from = "AutoLab<autolab@labguides.com>"
$mailmessage.To.add($emailto)
$Summary = "Completed AutoLab VM build.`r`n"
$Summary += "The build of $env:computername has finished, installing VMware Tools and rebooting`r`n"
$Summary += "The build log is attached`r`n"
$mailmessage.Subject = "$env:computername VM build finished"
$mailmessage.Body = $Summary
$attach = new-object Net.Mail.Attachment("C:\buildlog.txt")
$mailmessage.Attachments.Add($attach)
$SMTPClient.Send($mailmessage)
}
Exit Exit
} }
Write-BuildLog "Install Flash Player"
Start-Process msiexec -wait -ArgumentList " /i b:\Automate\_Common\install_flash_player_11_active_x.msi /qn" browserAndFlash
Write-BuildLog "Setup Firewall" Write-BuildLog "Setup Firewall"
netsh advfirewall firewall add rule name="All ICMP V4" dir=in action=allow protocol=icmpv4 netsh advfirewall firewall add rule name="All ICMP V4" dir=in action=allow protocol=icmpv4
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
@ -80,32 +131,15 @@ route add 192.168.201.0 mask 255.255.255.0 192.168.199.254 -p
Write-BuildLog "Cleanup" Write-BuildLog "Cleanup"
regedit /s b:\Automate\_Common\ExecuPol.reg regedit /s b:\Automate\_Common\ExecuPol.reg
regedit -s b:\Automate\_Common\NoSCRNSave.reg regedit -s b:\Automate\_Common\NoSCRNSave.reg
Write-BuildLog "Change default local administrator password"
net user administrator $AdminPWD
B:\automate\_Common\Autologon administrator CS2 $AdminPWD
Write-BuildLog "Copy Connection server install and setup recall" Write-BuildLog "Copy Connection server install and setup recall"
$Files = get-childitem "b:\view$viewinstall" $Files = get-childitem "b:\view$viewinstall"
for ($i=0; $i -lt $files.Count; $i++) { for ($i=0; $i -lt $files.Count; $i++) {
If ($Files[$i].Name -like "VMware-viewconnectionserver*") {$Installer = $Files[$i].FullName} If ($Files[$i].Name -like "VMware-viewconnectionserver*") {$Installer = $Files[$i].FullName}
} }
copy $Installer C:\ copy $Installer C:\
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f >> c:\buildlog.txt reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f
Write-BuildLog "Install VMware Tools" Write-BuildLog "Install VMware Tools"
b:\VMTools\Setup64.exe /s /v "/qn" b:\VMTools\Setup64.exe /s /v "/qn"
if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none")){
$mailmessage = New-Object system.net.mail.mailmessage
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$mailmessage.from = "AutoLab<autolab@labguides.com>"
$mailmessage.To.add($emailto)
$Summary = "Completed AutoLab VM build.`r`n"
$Summary += "The build of $env:computername has finished, installing VMware Tools and rebooting`r`n"
$Summary += "The build log is attached`r`n"
$mailmessage.Subject = "$env:computername VM build finished"
$mailmessage.Body = $Summary
$attach = new-object Net.Mail.Attachment("C:\buildlog.txt")
$mailmessage.Attachments.Add($attach)
$SMTPClient.Send($mailmessage)
}
Read-Host "Reboot?" Read-Host "Reboot?"

View File

@ -1,4 +1,6 @@
@echo off @echo off
echo * Begining Phase2.cmd as %userdomain%\%username%
echo * Begining Phase2.cmd as %userdomain%\%username% >> c:\buildlog.txt
net use B: \\192.168.199.7\Build net use B: \\192.168.199.7\Build
ver | find "6.1" > nul ver | find "6.1" > nul
if %ERRORLEVEL% == 0 goto ver_2K8 if %ERRORLEVEL% == 0 goto ver_2K8
@ -6,36 +8,21 @@ ver | find "6.2" > nul
if %ERRORLEVEL% == 0 goto ver_2K12 if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "6.3" > nul ver | find "6.3" > nul
if %ERRORLEVEL% == 0 goto ver_2K12 if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "10.0" > nul
if %ERRORLEVEL% == 0 goto ver_2K16
Exit Exit
:ver_2K12
If Exist C:\Windows\SYSVOL\* Goto ver_2K8
echo * Install DHCP and DNS
echo * Install DHCP and DNS >> c:\buildlog.txt
Dism /online /enable-feature /featurename:DHCPServer /quiet
Dism /online /enable-feature /featurename:DHCPServer-Tools /all /quiet
Dism /online /enable-feature /featurename:DNS-Server-Full-Role /quiet
Dism /online /enable-feature /featurename:DNS-Server-Tools /all /quiet
echo * Install AD DC Role
echo * Install AD DC Role >> c:\buildlog.txt
Dism /online /enable-feature /featurename:DirectoryServices-DomainController /all /quiet
Dism /online /enable-feature /featurename:DirectoryServices-AdministrativeCenter /all /quiet
Dism /online /enable-feature /featurename:ActiveDirectory-PowerShell /all /quiet
sc config dhcpserver start= auto
regedit -s B:\Automate\_Common\ExecuPol.reg
regedit -s B:\Automate\_Common\NoSCRNSave.reg
regedit -s B:\Automate\_Common\ExplorerView.reg
regedit -s b:\Automate\_Common\Nested.reg
echo * Promote to DC
echo * Promote to DC >> c:\buildlog.txt
copy \\192.168.199.7\Build\Automate\DC\dcpromo.ps1 c:\
powershell c:\dcpromo.ps1
pause
:ver_2K8 :ver_2K8
echo * Install services on Windows 2008
echo * Install services on Windows 2008 >> c:\buildlog.txt
Dism /online /enable-feature /featurename:DHCPServerCore >> c:\buildlog.txt
Dism /online /enable-feature /featurename:DNS-Server-Full-Role >> c:\buildlog.txt
sc config dhcpserver start= auto >> c:\buildlog.txt
:ver_2K12
:ver_2K16
echo ** echo **
echo * Connect to build share echo * Connect to build share
echo * Connect to build share >> c:\buildlog.txt echo * Connect to build share >> c:\buildlog.txt
net use B: \\192.168.199.7\Build net use b: \\192.168.199.7\Build
type B:\automate\version.txt >> C:\buildlog.txt
echo ** echo **
echo * Copy PowerShell files echo * Copy PowerShell files
echo * Copy PowerShell files >> c:\buildlog.txt echo * Copy PowerShell files >> c:\buildlog.txt
@ -53,5 +40,4 @@ cscript //B "%windir%\system32\slmgr.vbs" /ato
echo * Starting PowerShell script for Phase 2 completion echo * Starting PowerShell script for Phase 2 completion
echo * Starting PowerShell script for Phase 2 completion >> C:\buildlog.txt echo * Starting PowerShell script for Phase 2 completion >> C:\buildlog.txt
powershell c:\Phase2.ps1 powershell c:\Phase2.ps1
if exist C:\phase2.ps1 del c:\phase2.ps1 exit
if exist c:\phase2.cmd del c:\phase2.cmd

View File

@ -6,6 +6,31 @@ if (Test-Path C:\PSFunctions.ps1) {
exit exit
} }
if((get-process "dcpromo" -ea SilentlyContinue) -ne $Null){
write-buildlog "DCPromo still in progress, closing"
exit
}
Try {
Get-ADDomainController -Discover -ea SilentlyContinue
} catch {
write-buildlog "Not yet a domain controller, DCPromo"
#Install-Windowsfeature AD-Domain-Services,DNS -IncludeManagementTools
$null = Add-WindowsFeature -name ad-domain-services -IncludeManagementTools
$safemodeadminpwd = ConvertTo-SecureString -String "VMware1!" -asplaintext -force
Write-buildlog "Install-ADDSForest"
$null = Install-ADDSForest -DomainName "lab.local" -ForestMode Win2008R2 -DomainMode Win2008R2 -SafeModeAdministratorPassword $safemodeadminpwd -Force
exit
}
write-buildlog "Starting Phase2.ps1"
$a = (Get-Host).UI.RawUI
$a.WindowTitle = "DC Build Automation"
$b = $a.WindowSize
$b.Height = $a.MaxWindowSize.Height - 1
$a.WindowSize = $b
Import-Module C:\windows\system32\WASP.dll
Select-Window -Title "DC Build Automation" | set-windowposition -left 75 -top 3
# Start DC configuration process # Start DC configuration process
if (Test-Path B:\Automate\automate.ini) { if (Test-Path B:\Automate\automate.ini) {
$KMSIP = "0.0.0.0" $KMSIP = "0.0.0.0"
@ -45,13 +70,12 @@ if (Test-Path B:\Automate\automate.ini) {
Write-BuildLog "Installing 7-zip." Write-BuildLog "Installing 7-zip."
try { try {
msiexec /qb /i B:\Automate\_Common\7z920-x64.msi msiexec /qb /i B:\Automate\_Common\7z1805-x64.msi
Write-BuildLog "Installation of 7-zip completed." Write-BuildLog "Installation of 7-zip completed."
} }
catch { catch {
Write-BuildLog "7-zip installation failed." Write-BuildLog "7-zip installation failed."
} }
Write-BuildLog ""
if (Test-Path "b:\VMware-PowerCLI.exe") { if (Test-Path "b:\VMware-PowerCLI.exe") {
$PowCLIver = (Get-ChildItem B:\VMware-PowerCLI.exe).VersionInfo.ProductVersion.trim() $PowCLIver = (Get-ChildItem B:\VMware-PowerCLI.exe).VersionInfo.ProductVersion.trim()
if ($PowCLIver -eq "5.0.0.3501") {$PowCLIver = "5.0.0-3501"} if ($PowCLIver -eq "5.0.0.3501") {$PowCLIver = "5.0.0-3501"}
@ -75,7 +99,6 @@ if (Test-Path "C:\Program Files\Tftpd64_SE\Tftpd64_SVC.exe") {
Write-BuildLog "Copying B:\Automate\DC\TFTP-Root\ contents to C:\TFTP-Root." Write-BuildLog "Copying B:\Automate\DC\TFTP-Root\ contents to C:\TFTP-Root."
xcopy B:\Automate\DC\TFTP-Root\*.* C:\TFTP-Root\ /s /c /y /q xcopy B:\Automate\DC\TFTP-Root\*.* C:\TFTP-Root\ /s /c /y /q
Write-BuildLog "Installation of TFTP completed." Write-BuildLog "Installation of TFTP completed."
Write-BuildLog ""
} }
Write-BuildLog "Set root password for ESXi builds" Write-BuildLog "Set root password for ESXi builds"
@ -99,6 +122,54 @@ $TempContent = Get-Content B:\Automate\Hosts\esx12-5.cfg |%{$_ -replace "VMware1
$TempContent | Set-Content B:\Automate\Hosts\esx12-5.cfg $TempContent | Set-Content B:\Automate\Hosts\esx12-5.cfg
Write-BuildLog "Checking for vSphere files..." Write-BuildLog "Checking for vSphere files..."
if (Test-Path "B:\ESXi67\*") {
if ((Test-Path "B:\ESXi67\*.iso") -and !(Test-Path "B:\ESXi67\BOOT.CFG") ){
Write-BuildLog "Extracting ESXi 6.7 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESXi67\ B:\ESXi67\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESXi 6.7 found; creating C:\TFTP-Root\ESXi67 and copying ESXi 67 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESXi67 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESXi67\*.* C:\TFTP-Root\ESXi67\ /s /c /y /q
Get-Content C:\TFTP-Root\ESXi67\BOOT.CFG | %{$_ -replace "/","/ESXi67/"} | Set-Content C:\TFTP-Root\ESXi67\Besx1-67.cfg
Add-Content C:\TFTP-Root\ESXi67\Besx1-67.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx1-5.cfg"
Get-Content C:\TFTP-Root\ESXi67\BOOT.CFG | %{$_ -replace "/","/ESXi67/"} | Set-Content C:\TFTP-Root\ESXi67\Besx2-67.cfg
Add-Content C:\TFTP-Root\ESXi67\Besx2-67.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx2-5.cfg"
Get-Content C:\TFTP-Root\ESXi67\BOOT.CFG | %{$_ -replace "/","/ESXi67/"} | Set-Content C:\TFTP-Root\ESXi67\Besx3-67.cfg
Add-Content C:\TFTP-Root\ESXi67\Besx3-67.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg"
Get-Content C:\TFTP-Root\ESXi67\BOOT.CFG | %{$_ -replace "/","/ESXi67/"} | Set-Content C:\TFTP-Root\ESXi67\Besx4-67.cfg
Add-Content C:\TFTP-Root\ESXi67\Besx4-67.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg"
Get-Content C:\TFTP-Root\ESXi67\BOOT.CFG | %{$_ -replace "/","/ESXi67/"} | Set-Content C:\TFTP-Root\ESXi67\BOOTM.CFG
powershell C:\PXEMenuConfig.ps1 ESXi67
Write-BuildLog "ESXi 6.7 added to TFTP and PXE menu."
$esxi67 = $true
} else {
$esxi67 = $false
}
if (Test-Path "B:\ESXi65\*") {
if ((Test-Path "B:\ESXi65\*.iso") -and !(Test-Path "B:\ESXi65\BOOT.CFG") ){
Write-BuildLog "Extracting ESXi 6.5 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESXi65\ B:\ESXi65\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESXi 6.5 found; creating C:\TFTP-Root\ESXi65 and copying ESXi 65 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESXi65 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESXi65\*.* C:\TFTP-Root\ESXi65\ /s /c /y /q
Get-Content C:\TFTP-Root\ESXi65\BOOT.CFG | %{$_ -replace "/","/ESXi65/"} | Set-Content C:\TFTP-Root\ESXi65\Besx1-65.cfg
Add-Content C:\TFTP-Root\ESXi65\Besx1-65.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx1-5.cfg"
Get-Content C:\TFTP-Root\ESXi65\BOOT.CFG | %{$_ -replace "/","/ESXi65/"} | Set-Content C:\TFTP-Root\ESXi65\Besx2-65.cfg
Add-Content C:\TFTP-Root\ESXi65\Besx2-65.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx2-5.cfg"
Get-Content C:\TFTP-Root\ESXi65\BOOT.CFG | %{$_ -replace "/","/ESXi65/"} | Set-Content C:\TFTP-Root\ESXi65\Besx3-65.cfg
Add-Content C:\TFTP-Root\ESXi65\Besx3-65.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg"
Get-Content C:\TFTP-Root\ESXi65\BOOT.CFG | %{$_ -replace "/","/ESXi65/"} | Set-Content C:\TFTP-Root\ESXi65\Besx4-65.cfg
Add-Content C:\TFTP-Root\ESXi65\Besx4-65.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg"
Get-Content C:\TFTP-Root\ESXi65\BOOT.CFG | %{$_ -replace "/","/ESXi65/"} | Set-Content C:\TFTP-Root\ESXi65\BOOTM.CFG
powershell C:\PXEMenuConfig.ps1 ESXi65
Write-BuildLog "ESXi 6.5 added to TFTP and PXE menu."
$esxi65 = $true
} else {
$esxi65 = $false
}
if (Test-Path "B:\ESXi60\*") { if (Test-Path "B:\ESXi60\*") {
if ((Test-Path "B:\ESXi60\*.iso") -and !(Test-Path "B:\ESXi60\BOOT.CFG") ){ if ((Test-Path "B:\ESXi60\*.iso") -and !(Test-Path "B:\ESXi60\BOOT.CFG") ){
Write-BuildLog "Extracting ESXi 6.0 installer from ISO." Write-BuildLog "Extracting ESXi 6.0 installer from ISO."
@ -115,10 +186,9 @@ if (Test-Path "B:\ESXi60\*") {
Add-Content C:\TFTP-Root\ESXi60\Besx3-60.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg" Add-Content C:\TFTP-Root\ESXi60\Besx3-60.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg"
Get-Content C:\TFTP-Root\ESXi60\BOOT.CFG | %{$_ -replace "/","/ESXi60/"} | Set-Content C:\TFTP-Root\ESXi60\Besx4-60.cfg Get-Content C:\TFTP-Root\ESXi60\BOOT.CFG | %{$_ -replace "/","/ESXi60/"} | Set-Content C:\TFTP-Root\ESXi60\Besx4-60.cfg
Add-Content C:\TFTP-Root\ESXi60\\Besx4-60.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg" Add-Content C:\TFTP-Root\ESXi60\\Besx4-60.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg"
Get-Content C:\TFTP-Root\ESXi60\BOOT.CFG | %{$_ -replace "/","/ESXi60/"} | Set-Content C:\TFTP-Root\ESXi60\BOOT.CFG Get-Content C:\TFTP-Root\ESXi60\BOOT.CFG | %{$_ -replace "/","/ESXi60/"} | Set-Content C:\TFTP-Root\ESXi60\BOOTM.CFG
powershell C:\PXEMenuConfig.ps1 ESXi60 powershell C:\PXEMenuConfig.ps1 ESXi60
Write-BuildLog "ESXi 6.0 added to TFTP and PXE menu." Write-BuildLog "ESXi 6.0 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi60 = $true $esxi60 = $true
} else { } else {
$esxi60 = $false $esxi60 = $false
@ -140,10 +210,9 @@ if (Test-Path "B:\ESXi55\*") {
Add-Content C:\TFTP-Root\ESXi55\Besx3-55.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg" Add-Content C:\TFTP-Root\ESXi55\Besx3-55.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg"
Get-Content C:\TFTP-Root\ESXi55\BOOT.CFG | %{$_ -replace "/","/ESXi55/"} | Set-Content C:\TFTP-Root\ESXi55\Besx4-55.cfg Get-Content C:\TFTP-Root\ESXi55\BOOT.CFG | %{$_ -replace "/","/ESXi55/"} | Set-Content C:\TFTP-Root\ESXi55\Besx4-55.cfg
Add-Content C:\TFTP-Root\ESXi55\\Besx4-55.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg" Add-Content C:\TFTP-Root\ESXi55\\Besx4-55.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg"
Get-Content C:\TFTP-Root\ESXi55\BOOT.CFG | %{$_ -replace "/","/ESXi55/"} | Set-Content C:\TFTP-Root\ESXi55\BOOT.CFG Get-Content C:\TFTP-Root\ESXi55\BOOT.CFG | %{$_ -replace "/","/ESXi55/"} | Set-Content C:\TFTP-Root\ESXi55\BOOTM.CFG
powershell C:\PXEMenuConfig.ps1 ESXi55 powershell C:\PXEMenuConfig.ps1 ESXi55
Write-BuildLog "ESXi 5.5 added to TFTP and PXE menu." Write-BuildLog "ESXi 5.5 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi55 = $true $esxi55 = $true
} else { } else {
$esxi55 = $false $esxi55 = $false
@ -165,10 +234,9 @@ if (Test-Path "B:\ESXi51\*") {
Add-Content C:\TFTP-Root\ESXi51\Besx3-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg" Add-Content C:\TFTP-Root\ESXi51\Besx3-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg"
Get-Content C:\TFTP-Root\ESXi51\BOOT.CFG | %{$_ -replace "/","/ESXi51/"} | Set-Content C:\TFTP-Root\ESXi51\Besx4-5.cfg Get-Content C:\TFTP-Root\ESXi51\BOOT.CFG | %{$_ -replace "/","/ESXi51/"} | Set-Content C:\TFTP-Root\ESXi51\Besx4-5.cfg
Add-Content C:\TFTP-Root\ESXi51\Besx4-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg" Add-Content C:\TFTP-Root\ESXi51\Besx4-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg"
Get-Content C:\TFTP-Root\ESXi51\BOOT.CFG | %{$_ -replace "/","/ESXi51/"} | Set-Content C:\TFTP-Root\ESXi51\BOOT.CFG Get-Content C:\TFTP-Root\ESXi51\BOOT.CFG | %{$_ -replace "/","/ESXi51/"} | Set-Content C:\TFTP-Root\ESXi51\BOOTM.CFG
powershell C:\PXEMenuConfig.ps1 ESXi51 powershell C:\PXEMenuConfig.ps1 ESXi51
Write-BuildLog "ESXi 5.1 added to TFTP and PXE menu." Write-BuildLog "ESXi 5.1 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi51 = $true $esxi51 = $true
} else { } else {
$esxi51 = $false $esxi51 = $false
@ -190,10 +258,9 @@ if (Test-Path "B:\ESXi50\*") {
Add-Content C:\TFTP-Root\ESXi50\Besx3-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg" Add-Content C:\TFTP-Root\ESXi50\Besx3-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg"
Get-Content C:\TFTP-Root\ESXi50\BOOT.CFG | %{$_ -replace "/","/ESXi50/"} | Set-Content C:\TFTP-Root\ESXi50\Besx4-5.cfg Get-Content C:\TFTP-Root\ESXi50\BOOT.CFG | %{$_ -replace "/","/ESXi50/"} | Set-Content C:\TFTP-Root\ESXi50\Besx4-5.cfg
Add-Content C:\TFTP-Root\ESXi50\Besx4-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg" Add-Content C:\TFTP-Root\ESXi50\Besx4-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg"
Get-Content C:\TFTP-Root\ESXi50\BOOT.CFG | %{$_ -replace "/","/ESXi50/"} | Set-Content C:\TFTP-Root\ESXi50\BOOT.CFG Get-Content C:\TFTP-Root\ESXi50\BOOT.CFG | %{$_ -replace "/","/ESXi50/"} | Set-Content C:\TFTP-Root\ESXi50\BOOTM.CFG
powershell C:\PXEMenuConfig.ps1 ESXi50 powershell C:\PXEMenuConfig.ps1 ESXi50
Write-BuildLog "ESXi 5.0 added to TFTP and PXE menu." Write-BuildLog "ESXi 5.0 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi50 = $true $esxi50 = $true
} else { } else {
$esxi50 = $false $esxi50 = $false
@ -215,7 +282,6 @@ if (Test-Path "B:\ESXi41\*") {
xcopy B:\ESXi41\mboot.c32 C:\TFTP-Root\ESXi41 /s /c /y /q xcopy B:\ESXi41\mboot.c32 C:\TFTP-Root\ESXi41 /s /c /y /q
powershell C:\PXEMenuConfig.ps1 ESXi41 powershell C:\PXEMenuConfig.ps1 ESXi41
Write-BuildLog "ESXi 4.1 added to TFTP and PXE menu." Write-BuildLog "ESXi 4.1 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi41 = $true $esxi41 = $true
} else { } else {
$esxi41 = $false $esxi41 = $false
@ -232,13 +298,12 @@ if (Test-Path "B:\ESX41\*") {
xcopy B:\ESX41\isolinux\initrd.img C:\TFTP-Root\ESX41 /s /c /y /q xcopy B:\ESX41\isolinux\initrd.img C:\TFTP-Root\ESX41 /s /c /y /q
powershell C:\PXEMenuConfig.ps1 ESX41 powershell C:\PXEMenuConfig.ps1 ESX41
Write-BuildLog "ESX 4.1 added to TFTP and PXE menu." Write-BuildLog "ESX 4.1 added to TFTP and PXE menu."
Write-BuildLog ""
$esx41 = $true $esx41 = $true
} else { } else {
$esx41 = $false $esx41 = $false
} }
if (!($esx41 -or $esxi41 -or $esxi50 -or $esxi51 -or $esxi55 -or $esxi60)) { if (!($esx41 -or $esxi41 -or $esxi50 -or $esxi51 -or $esxi55 -or $esxi60 -or $esxi65 -or $esxi67)) {
Write-BuildLog "No ESX or ESXi files found." Write-BuildLog "No ESX or ESXi files found."
Write-BuildLog "Is the NAS VM running? If so, make sure the Build share is available and populated." Write-BuildLog "Is the NAS VM running? If so, make sure the Build share is available and populated."
Write-BuildLog "Restart this machine when Build share is available; build will proceed after restart." Write-BuildLog "Restart this machine when Build share is available; build will proceed after restart."
@ -254,16 +319,39 @@ if (Test-Path "B:\gParted\*") {
LABEL gParted LABEL gParted
MENU LABEL gParted utility MENU LABEL gParted utility
kernel gparted/vmlinuz kernel gparted/vmlinuz
append initrd=gparted/initrd.img boot=live config components union=overlay username=user noswap noeject ip= vga=788 fetch=tftp://192.168.199.4/gparted/filesystem.squashfs append initrd=gparted/initrd.img boot=live config components union=overlay username=user noswap noeject ip= vga=788 fetch=tftp://\\dc.lab.local/gparted/filesystem.squashfs
"@ "@
} }
Write-BuildLog "Checking for vCenter files..." Write-BuildLog "Checking for vCenter files..."
if (Test-Path "B:\VIM_67\*") {
if ((Test-Path "B:\VIM_67\*.iso") -and !(Test-Path "B:\VIM_67\autorun.exe")){
Write-BuildLog "Extracting vCenter 6.7 installer from ISO."
start-process "C:\Program Files\7-Zip\7z.exe" -ArgumentList " x -r -y -aoa -oB:\VIM_67\ B:\VIM_67\*.iso" -RedirectStandardOutput C:\ExtractLog.txt -wait
remove-item "B:\VIM_67\*.iso"
}
Write-BuildLog "vCenter 6.7 found."
$vCenter67 = $true
} else {
$vCenter67 = $false
}
if (Test-Path "B:\VIM_65\*") {
if ((Test-Path "B:\VIM_65\*.iso") -and !(Test-Path "B:\VIM_65\autorun.exe")){
Write-BuildLog "Extracting vCenter 6.5 installer from ISO."
start-process "C:\Program Files\7-Zip\7z.exe" -ArgumentList " x -r -y -aoa -oB:\VIM_65\ B:\VIM_65\*.iso" -RedirectStandardOutput C:\ExtractLog.txt -wait
remove-item "B:\VIM_65\*.iso"
}
Write-BuildLog "vCenter 6.5 found."
$vCenter65 = $true
} else {
$vCenter65 = $false
}
if (Test-Path "B:\VIM_60\*") { if (Test-Path "B:\VIM_60\*") {
if ((Test-Path "B:\VIM_60\*.iso") -and !(Test-Path "B:\VIM_60\autorun.exe")){ if ((Test-Path "B:\VIM_60\*.iso") -and !(Test-Path "B:\VIM_60\autorun.exe")){
Write-BuildLog "Extracting vCenter 6.0 installer from ISO." Write-BuildLog "Extracting vCenter 6.0 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VIM_60\ B:\VIM_60\*.iso >> C:\ExtractLog.txt start-process "C:\Program Files\7-Zip\7z.exe" -ArgumentList " x -r -y -aoa -oB:\VIM_60\ B:\VIM_60\*.iso" -RedirectStandardOutput C:\ExtractLog.txt -wait
} remove-item "B:\VIM_60\*.iso"
}
Write-BuildLog "vCenter 6.0 found." Write-BuildLog "vCenter 6.0 found."
$vCenter60 = $true $vCenter60 = $true
} else { } else {
@ -272,7 +360,8 @@ if (Test-Path "B:\VIM_60\*") {
if (Test-Path "B:\VIM_55\*") { if (Test-Path "B:\VIM_55\*") {
if ((Test-Path "B:\VIM_55\*.iso") -and !(Test-Path "B:\VIM_55\autorun.exe")){ if ((Test-Path "B:\VIM_55\*.iso") -and !(Test-Path "B:\VIM_55\autorun.exe")){
Write-BuildLog "Extracting vCenter 5.5 installer from ISO." Write-BuildLog "Extracting vCenter 5.5 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VIM_55\ B:\VIM_55\*.iso >> C:\ExtractLog.txt start-process "C:\Program Files\7-Zip\7z.exe" -ArgumentList " x -r -y -aoa -oB:\VIM_55\ B:\VIM_55\*.iso" -RedirectStandardOutput C:\ExtractLog.txt -wait
remove-item "B:\VIM_55\*.iso"
} }
Write-BuildLog "vCenter 5.5 found." Write-BuildLog "vCenter 5.5 found."
$vCenter55 = $true $vCenter55 = $true
@ -282,7 +371,8 @@ if (Test-Path "B:\VIM_55\*") {
if (Test-Path "B:\VIM_51\*") { if (Test-Path "B:\VIM_51\*") {
if ((Test-Path "B:\VIM_51\*.iso") -and !(Test-Path "B:\VIM_51\autorun.exe")) { if ((Test-Path "B:\VIM_51\*.iso") -and !(Test-Path "B:\VIM_51\autorun.exe")) {
Write-BuildLog "Extracting vCenter 5.1 installer from ISO." Write-BuildLog "Extracting vCenter 5.1 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VIM_51\ B:\VIM_51\*.iso >> C:\ExtractLog.txt start-process "C:\Program Files\7-Zip\7z.exe" -ArgumentList " x -r -y -aoa -oB:\VIM_51\ B:\VIM_51\*.iso" -RedirectStandardOutput C:\ExtractLog.txt -wait
remove-item "B:\VIM_51\*.iso"
} }
Write-BuildLog "vCenter 5.1 found." Write-BuildLog "vCenter 5.1 found."
$vCenter51 = $true $vCenter51 = $true
@ -293,7 +383,8 @@ if (Test-Path "B:\VIM_51\*") {
if (Test-Path "B:\VIM_50\*") { if (Test-Path "B:\VIM_50\*") {
if ((Test-Path "B:\VIM_50\*.iso") -and !(Test-Path "B:\VIM_50\autorun.exe")) { if ((Test-Path "B:\VIM_50\*.iso") -and !(Test-Path "B:\VIM_50\autorun.exe")) {
Write-BuildLog "Extracting vCenter 5.0 installer from ISO." Write-BuildLog "Extracting vCenter 5.0 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VIM_50\ B:\VIM_50\*.iso >> C:\ExtractLog.txt start-process "C:\Program Files\7-Zip\7z.exe" -ArgumentList " x -r -y -aoa -oB:\VIM_50\ B:\VIM_50\*.iso" -RedirectStandardOutput C:\ExtractLog.txt -wait
remove-item "B:\VIM_50\*.iso"
} }
Write-BuildLog "vCenter 5.0 found." Write-BuildLog "vCenter 5.0 found."
$vCenter50 = $true $vCenter50 = $true
@ -312,61 +403,66 @@ if (Test-Path "B:\VIM_41\*") {
$vCenter41 = $false $vCenter41 = $false
} }
if (!($vCenter41 -or $vCenter50 -or $vCenter51 -or $vCenter55 -or $vCenter60)) { if (!($vCenter41 -or $vCenter50 -or $vCenter51 -or $vCenter55 -or $vCenter60 -or $vCenter65 -or $vCenter67)) {
Write-BuildLog "No vCenter installation files found on Build share." Write-BuildLog "No vCenter installation files found on Build share."
Write-BuildLog "Is the NAS VM running? If so, make sure the Build share is available and populated." Write-BuildLog "Is the NAS VM running? If so, make sure the Build share is available and populated."
Write-BuildLog "Restart this machine when Build share is available; build will proceed after restart." Write-BuildLog "Restart this machine when Build share is available; build will proceed after restart."
exit exit
} }
if (!($vCenter67 -and $esxi67)) {
Write-BuildLog "vSphere 6.7 installation requirements not met."
$vSphere67 = $false
} else {
$vSphere67 = $true
}
if (!($vCenter65 -and $esxi65)) {
Write-BuildLog "vSphere 6.5 installation requirements not met."
$vSphere65 = $false
} else {
$vSphere65 = $true
}
if (!($vCenter60 -and $esxi60)) { if (!($vCenter60 -and $esxi60)) {
Write-BuildLog "vSphere 6.0 installation requirements not met. Please verify that both vCenter 6.0 & ESXi 6.0 exist on Build share." Write-BuildLog "vSphere 6.0 installation requirements not met."
$vSphere60 = $false $vSphere60 = $false
} else { } else {
$vSphere60 = $true $vSphere60 = $true
} }
if (!($vCenter55 -and $esxi55)) { if (!($vCenter55 -and $esxi55)) {
Write-BuildLog "vSphere 5.5 installation requirements not met. Please verify that both vCenter 5.5 & ESXi 5.5 exist on Build share." Write-BuildLog "vSphere 5.5 installation requirements not met."
$vSphere55 = $false $vSphere55 = $false
} else { } else {
$vSphere55 = $true $vSphere55 = $true
} }
if (!($vCenter51 -and $esxi51)) { if (!($vCenter51 -and $esxi51)) {
Write-BuildLog "vSphere 5.1 installation requirements not met. Please verify that both vCenter 5.1 & ESXi 5.1 exist on Build share." Write-BuildLog "vSphere 5.1 installation requirements not met."
$vSphere51 = $false $vSphere51 = $false
} else { } else {
$vSphere51 = $true $vSphere51 = $true
} }
if (!($vCenter50 -and $esxi50)) { if (!($vCenter50 -and $esxi50)) {
Write-BuildLog "vSphere 5.0 installation requirements not met. Please verify that both vCenter 5.0 & ESXi 5.0 exist on Build share." Write-BuildLog "vSphere 5.0 installation requirements not met."
$vSphere50 = $false $vSphere50 = $false
} else { } else {
$vSphere50 = $true $vSphere50 = $true
} }
if (!($vCenter41 -and ($esxi41 -or $esx41))) { if (!($vCenter41 -and ($esxi41 -or $esx41))) {
Write-BuildLog "vSphere 4.1 installation requirements not met. Please verify that both vCenter 4.1 & ESXi 4.1 exist on Build share." Write-BuildLog "vSphere 4.1 installation requirements not met."
$vSphere41 = $false $vSphere41 = $false
} else { } else {
$vSphere41 = $true $vSphere41 = $true
} }
if (!($vSphere41 -or $vSphere50 -or $vSphere51 -or $vSphere55 -or $vSphere60)) { if (!($vSphere41 -or $vSphere50 -or $vSphere51 -or $vSphere55 -or $vSphere60 -or $vSphere65 -or $vSphere67)) {
Write-BuildLog "Matching vCenter & ESXi distributions not found. Please check the Build share." Write-BuildLog "Matching vCenter & ESXi distributions not found. Please check the Build share."
} }
Write-BuildLog "" $PCLIver = deployPowerCLI
Write-BuildLog "Authorise and configure DHCP"
netsh dhcp server 192.168.199.4 set dnscredentials administrator lab.local $AdminPWD Write-BuildLog "Install, Authorise and configure DHCP"
netsh dhcp add server dc.lab.local 192.168.199.4 >> C:\DNS.log If ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62) {
netsh dhcp server 192.168.199.4 add scope 192.168.199.0 255.255.255.0 "Lab scope" "Scope for lab.local" >> C:\DNS.log $null = Add-WindowsFeature -IncludeManagementTools dhcp
netsh dhcp server 192.168.199.4 scope 192.168.199.0 add iprange 192.168.199.100 192.168.199.199 >> C:\DNS.log }
netsh dhcp server 192.168.199.4 scope 192.168.199.0 set optionvalue 003 IPADDRESS 192.168.199.2 >> C:\DNS.log
netsh dhcp server 192.168.199.4 scope 192.168.199.0 set optionvalue 005 IPADDRESS 192.168.199.4 >> C:\DNS.log
netsh dhcp server 192.168.199.4 scope 192.168.199.0 set optionvalue 006 IPADDRESS 192.168.199.4 >> C:\DNS.log
netsh dhcp server 192.168.199.4 scope 192.168.199.0 set optionvalue 015 STRING lab.local >> C:\DNS.log
netsh dhcp server 192.168.199.4 scope 192.168.199.0 set optionvalue 066 STRING 192.168.199.4 >> C:\DNS.log
netsh dhcp server 192.168.199.4 scope 192.168.199.0 set optionvalue 067 STRING pxelinux.0 >> C:\DNS.log
netsh dhcp server 192.168.199.4 scope 192.168.199.0 set state 1 >> C:\DNS.log
Write-BuildLog "Create DNS Records" Write-BuildLog "Create DNS Records"
dnscmd localhost /config /UpdateOptions 0x0 >> C:\DNS.log dnscmd localhost /config /UpdateOptions 0x0 >> C:\DNS.log
dnscmd localhost /config lab.local /allowupdate 1 >> C:\DNS.log dnscmd localhost /config lab.local /allowupdate 1 >> C:\DNS.log
@ -413,16 +509,46 @@ If (($KMSIP.Split("."))[0] -ne "0") {
Write-BuildLog "Setting DNS record for external KMS server IP address to $KMSIP according to automate.ini." Write-BuildLog "Setting DNS record for external KMS server IP address to $KMSIP according to automate.ini."
dnscmd DC /RecordAdd lab.local _vlmcs._tcp SRV 0 10 1688 $KMSIP >> C:\DNS.log dnscmd DC /RecordAdd lab.local _vlmcs._tcp SRV 0 10 1688 $KMSIP >> C:\DNS.log
} }
Write-BuildLog "Setup DHCP scope"
Write-BuildLog "" netsh dhcp server \\dc.lab.local set dnscredentials administrator lab.local $AdminPWD
netsh dhcp add server dc.lab.local 192.168.199.4 >> C:\DNS.log
netsh dhcp server \\dc.lab.local add scope 192.168.199.0 255.255.255.0 "Lab scope" "Scope for lab.local" >> C:\DNS.log
netsh dhcp server \\dc.lab.local scope 192.168.199.0 add iprange 192.168.199.100 192.168.199.199 >> C:\DNS.log
netsh dhcp server \\dc.lab.local scope 192.168.199.0 set optionvalue 003 IPADDRESS 192.168.199.2 >> C:\DNS.log
netsh dhcp server \\dc.lab.local scope 192.168.199.0 set optionvalue 005 IPADDRESS \\dc.lab.local >> C:\DNS.log
netsh dhcp server \\dc.lab.local scope 192.168.199.0 set optionvalue 006 IPADDRESS \\dc.lab.local >> C:\DNS.log
netsh dhcp server \\dc.lab.local scope 192.168.199.0 set optionvalue 015 STRING lab.local >> C:\DNS.log
netsh dhcp server \\dc.lab.local scope 192.168.199.0 set optionvalue 066 STRING \\dc.lab.local >> C:\DNS.log
netsh dhcp server \\dc.lab.local scope 192.168.199.0 set optionvalue 067 STRING pxelinux.0 >> C:\DNS.log
netsh dhcp server \\dc.lab.local scope 192.168.199.0 set state 1 >> C:\DNS.log
Write-BuildLog "Checking available SQL Express versions." Write-BuildLog "Checking available SQL Express versions."
$null = New-Item -Path C:\temp -ItemType Directory -Force -Confirm:$false $null = New-Item -Path C:\temp -ItemType Directory -Force -Confirm:$false
if (Test-Path "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe") { if (Test-Path "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe") {
Write-BuildLog "SQL Server Install found, not installing" Write-BuildLog "SQL Server Install found, not installing"
}Else { }Else {
if (Test-Path "B:\VIM_60\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") { if ((Test-Path "B:\VIM_67\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") -and ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)) {
$vc67SQL = $true
Write-BuildLog "SQL Server 2012 Express SP2 for vCenter 6.7 found; installing."
copy B:\VIM_67\redist\SQLEXPR\SQLEXPR_x64_ENU.exe C:\temp
$Arguments = '/IACCEPTSQLSERVERLICENSETERMS /action=Install /FEATURES=SQL,Tools /SQLSYSADMINACCOUNTS="Lab\Domain Admins" /SQLSVCACCOUNT="Lab\vi-admin" /SQLSVCPASSWORD="' + $AdminPWD + '" /AGTSVCACCOUNT="Lab\vi-admin" /AGTSVCPASSWORD="' + $AdminPWD + '" /ADDCURRENTUSERASSQLADMIN /SECURITYMODE=SQL /SAPWD="VMware1!" /INSTANCENAME=SQLExpress /BROWSERSVCSTARTUPTYPE="Automatic" /TCPENABLED=1 /NPENABLED=1 /SQLSVCSTARTUPTYPE=Automatic /q'
Start-Process C:\temp\SQLEXPR_x64_ENU.exe -ArgumentList $Arguments -Wait
del c:\TEMP\SQLEXPR_x64_ENU.EXE
Write-BuildLog "Creating Databases."
Start-Process "C:\Program Files\Microsoft SQL Server\110\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDB.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
regedit -s B:\Automate\DC\SQLTCP.reg
} elseif ((Test-Path "B:\VIM_65\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") -and ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)) {
$vc65SQL = $true
Write-BuildLog "SQL Server 2012 Express SP2 for vCenter 6.5 found; installing."
copy B:\VIM_65\redist\SQLEXPR\SQLEXPR_x64_ENU.exe C:\temp
$Arguments = '/IACCEPTSQLSERVERLICENSETERMS /action=Install /FEATURES=SQL,Tools /SQLSYSADMINACCOUNTS="Lab\Domain Admins" /SQLSVCACCOUNT="Lab\vi-admin" /SQLSVCPASSWORD="' + $AdminPWD + '" /AGTSVCACCOUNT="Lab\vi-admin" /AGTSVCPASSWORD="' + $AdminPWD + '" /ADDCURRENTUSERASSQLADMIN /SECURITYMODE=SQL /SAPWD="VMware1!" /INSTANCENAME=SQLExpress /BROWSERSVCSTARTUPTYPE="Automatic" /TCPENABLED=1 /NPENABLED=1 /SQLSVCSTARTUPTYPE=Automatic /q'
Start-Process C:\temp\SQLEXPR_x64_ENU.exe -ArgumentList $Arguments -Wait
del c:\TEMP\SQLEXPR_x64_ENU.EXE
Write-BuildLog "Creating Databases."
Start-Process "C:\Program Files\Microsoft SQL Server\110\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDB.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
regedit -s B:\Automate\DC\SQLTCP.reg
} elseif ((Test-Path "B:\VIM_60\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") -and ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)) {
$vc6SQL = $true $vc6SQL = $true
Write-BuildLog "SQL Server 2012 Express SP1 for vCenter 6.0 found; installing." Write-BuildLog "SQL Server 2012 Express SP2 for vCenter 6.0 found; installing."
copy B:\VIM_60\redist\SQLEXPR\SQLEXPR_x64_ENU.exe C:\temp copy B:\VIM_60\redist\SQLEXPR\SQLEXPR_x64_ENU.exe C:\temp
$Arguments = '/IACCEPTSQLSERVERLICENSETERMS /action=Install /FEATURES=SQL,Tools /SQLSYSADMINACCOUNTS="Lab\Domain Admins" /SQLSVCACCOUNT="Lab\vi-admin" /SQLSVCPASSWORD="' + $AdminPWD + '" /AGTSVCACCOUNT="Lab\vi-admin" /AGTSVCPASSWORD="' + $AdminPWD + '" /ADDCURRENTUSERASSQLADMIN /SECURITYMODE=SQL /SAPWD="VMware1!" /INSTANCENAME=SQLExpress /BROWSERSVCSTARTUPTYPE="Automatic" /TCPENABLED=1 /NPENABLED=1 /SQLSVCSTARTUPTYPE=Automatic /q' $Arguments = '/IACCEPTSQLSERVERLICENSETERMS /action=Install /FEATURES=SQL,Tools /SQLSYSADMINACCOUNTS="Lab\Domain Admins" /SQLSVCACCOUNT="Lab\vi-admin" /SQLSVCPASSWORD="' + $AdminPWD + '" /AGTSVCACCOUNT="Lab\vi-admin" /AGTSVCPASSWORD="' + $AdminPWD + '" /ADDCURRENTUSERASSQLADMIN /SECURITYMODE=SQL /SAPWD="VMware1!" /INSTANCENAME=SQLExpress /BROWSERSVCSTARTUPTYPE="Automatic" /TCPENABLED=1 /NPENABLED=1 /SQLSVCSTARTUPTYPE=Automatic /q'
Start-Process C:\temp\SQLEXPR_x64_ENU.exe -ArgumentList $Arguments -Wait Start-Process C:\temp\SQLEXPR_x64_ENU.exe -ArgumentList $Arguments -Wait
@ -467,10 +593,12 @@ if (Test-Path "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe")
Start-Process "C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDB41.txt" -RedirectStandardOutput c:\sqllog.txt -Wait; type C:\sqllog.txt | add-content C:\buildlog.txt Start-Process "C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDB41.txt" -RedirectStandardOutput c:\sqllog.txt -Wait; type C:\sqllog.txt | add-content C:\buildlog.txt
regedit -s B:\Automate\DC\SQLTCP.reg regedit -s B:\Automate\DC\SQLTCP.reg
} else { } else {
$vc67SQL = $false
$vc65SQL = $false
$vc6SQL = $false $vc6SQL = $false
$vc5SQL = $false $vc5SQL = $false
$vc4SQL = $false $vc4SQL = $false
Write-BuildLog "No SQL Express installers found. Please verify that all contents of vCenter ISO are copied into the correct folder on the Build share." Write-BuildLog "No compatible SQL Express installers found. Please verify that all contents of vCenter ISO are copied into the correct folder on the Build share."
Read-Host "Press <ENTER> to exit" Read-Host "Press <ENTER> to exit"
exit exit
} }
@ -481,7 +609,7 @@ if (Test-Path B:\sqlmsssetup.exe) {
If (((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -le 61)) { If (((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -le 61)) {
Write-BuildLog "Doing Windows Server 2008 specific build actions" Write-BuildLog "Doing Windows Server 2008 specific build actions"
if (Test-Path B:\SQLManagementStudio_x64_ENU.exe) { if (Test-Path B:\SQLManagementStudio_x64_ENU.exe) {
if ( (!(Get-ChildItem B:\SQLManagementStudio_x64_ENU.exe).VersionInfo.ProductVersion -like "10.50.2500*") -and ($vc6SQL -or $vc5SQL -or $vc4SQL)) { if ( (!(Get-ChildItem B:\SQLManagementStudio_x64_ENU.exe).VersionInfo.ProductVersion -like "10.50.2500*") -and ($vc67SQL -or$vc65SQL -or $vc6SQL -or $vc5SQL -or $vc4SQL)) {
Write-BuildLog "The version of SQL Management Studio on the Build share is incompatible with SQL Server 2008 Express R2 SP1. Please see ReadMe.html on the Build share." Write-BuildLog "The version of SQL Management Studio on the Build share is incompatible with SQL Server 2008 Express R2 SP1. Please see ReadMe.html on the Build share."
} else { } else {
Write-BuildLog "SQL Management Studio found; installing." Write-BuildLog "SQL Management Studio found; installing."
@ -498,13 +626,13 @@ If (((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]:
} }
} }
If (((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)) { If (((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)) {
Write-BuildLog "Doing Windows Server 2012 specific build actions" Write-BuildLog "Doing Windows Server 2012 and 2016 specific build actions"
Write-BuildLog "Disabling autorun of ServerManager at logon." Write-BuildLog "Disabling autorun of ServerManager at logon."
Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs
Write-BuildLog "Disabling screen saver" Write-BuildLog "Disabling screen saver"
set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0 set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0
Write-BuildLog "Installing Administration tools." Write-BuildLog "Installing.Net Framework 3.5"
Install-WindowsFeature Name RSAT-DHCP,RSAT-DNS-Server,Net-Framework-Core $null = Install-WindowsFeature Net-Framework-Core -source D:\Sources\sxs
if (Test-Path B:\SQLManagementStudio_x64_ENU.exe) { if (Test-Path B:\SQLManagementStudio_x64_ENU.exe) {
if ( (!(Get-ChildItem B:\SQLManagementStudio_x64_ENU.exe).VersionInfo.ProductVersion -like "10.50.2500*") -and ($vc6SQL -or $vc5SQL -or $vc4SQL)) { if ( (!(Get-ChildItem B:\SQLManagementStudio_x64_ENU.exe).VersionInfo.ProductVersion -like "10.50.2500*") -and ($vc6SQL -or $vc5SQL -or $vc4SQL)) {
Write-BuildLog "The version of SQL Management Studio on the Build share is incompatible with SQL Server 2008 Express R2 SP1. Please see ReadMe.html on the Build share." Write-BuildLog "The version of SQL Management Studio on the Build share is incompatible with SQL Server 2008 Express R2 SP1. Please see ReadMe.html on the Build share."
@ -513,7 +641,7 @@ If (((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]:
Start-Process B:\SQLManagementStudio_x64_ENU.exe -ArgumentList "/ACTION=INSTALL /IACCEPTSQLSERVERLICENSETERMS /FEATURES=Tools /q" -Wait -Verb RunAs Start-Process B:\SQLManagementStudio_x64_ENU.exe -ArgumentList "/ACTION=INSTALL /IACCEPTSQLSERVERLICENSETERMS /FEATURES=Tools /q" -Wait -Verb RunAs
} }
} else { Write-BuildLog "SQL Management Studio not found (optional)."} } else { Write-BuildLog "SQL Management Studio not found (optional)."}
Write-BuildLog "Setup IIS on Windows 2012" Write-BuildLog "Setup IIS on Windows 2012 or 2016"
import-module servermanager import-module servermanager
If (Test-Path "D:\Sources\sxs\*") {$null = add-windowsfeature web-server -includeallsubfeature -source D:\Sources\sxs} If (Test-Path "D:\Sources\sxs\*") {$null = add-windowsfeature web-server -includeallsubfeature -source D:\Sources\sxs}
If (Test-Path "E:\Sources\sxs\*") {$null = add-windowsfeature web-server -includeallsubfeature -source E:\Sources\sxs} If (Test-Path "E:\Sources\sxs\*") {$null = add-windowsfeature web-server -includeallsubfeature -source E:\Sources\sxs}
@ -521,7 +649,7 @@ If (((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]:
New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https
Write-BuildLog "Setup Certificate Authority & web enrollment." Write-BuildLog "Setup Certificate Authority & web enrollment."
Import-Module ServerManager Import-Module ServerManager
Add-WindowsFeature AD-Certificate, Adcs-Cert-Authority, Adcs-Enroll-Web-Pol, Adcs-Enroll-Web-Svc, Adcs-Web-Enrollment , Adcs-Device-Enrollment , Adcs-Online-Cert -IncludeManagementTools $null = Add-WindowsFeature AD-Certificate, Adcs-Cert-Authority, Adcs-Enroll-Web-Pol, Adcs-Enroll-Web-Svc, Adcs-Web-Enrollment , Adcs-Device-Enrollment , Adcs-Online-Cert -IncludeManagementTools
copy B:\Automate\DC\setupca.vbs C:\temp copy B:\Automate\DC\setupca.vbs C:\temp
Cscript C:\temp\setupca.vbs /is /iw /sn LabCA /sk 4096 /sp "RSA#Microsoft Software Key Storage Provider" /sa SHA256 >> c:\SetupCA.log Cscript C:\temp\setupca.vbs /is /iw /sn LabCA /sk 4096 /sp "RSA#Microsoft Software Key Storage Provider" /sa SHA256 >> c:\SetupCA.log
import-module webadministration import-module webadministration
@ -543,6 +671,8 @@ Write-BuildLog "Cleanup and creating Desktop shortcuts."
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f
wscript B:\Automate\DC\Shortcuts.vbs wscript B:\Automate\DC\Shortcuts.vbs
browserAndFlash
if (Test-Path B:\Automate\automate.ini) { if (Test-Path B:\Automate\automate.ini) {
$timezone = ((Select-String -SimpleMatch "TZ=" -Path "B:\Automate\automate.ini").line).substring(3) $timezone = ((Select-String -SimpleMatch "TZ=" -Path "B:\Automate\automate.ini").line).substring(3)
Write-BuildLog "Setting time zone to $timezone according to automate.ini." Write-BuildLog "Setting time zone to $timezone according to automate.ini."
@ -562,6 +692,16 @@ if (Test-Path -Path "B:\VMTools\setup*") {
cd c:\temp cd c:\temp
$vcinstall = ((Select-String -SimpleMatch "VCInstall=" -Path "B:\Automate\automate.ini").line).substring(10) $vcinstall = ((Select-String -SimpleMatch "VCInstall=" -Path "B:\Automate\automate.ini").line).substring(10)
switch ($vcinstall) { switch ($vcinstall) {
67 {
B:\Automate\_Common\wget.exe -nd http://packages.vmware.com/tools/esx/6.0/windows/VMware-tools-windows-9.10.0-2476743.iso --no-check-certificate -awget.log
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VMtools\ c:\temp\VMware-tools-windows-9.10.0-2476743.iso >> C:\ExtractLog.txt
Write-BuildLog "VMware Tools V6.0 Downloaded and extracted to build share."
}
65 {
B:\Automate\_Common\wget.exe -nd http://packages.vmware.com/tools/esx/6.0/windows/VMware-tools-windows-9.10.0-2476743.iso --no-check-certificate -awget.log
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VMtools\ c:\temp\VMware-tools-windows-9.10.0-2476743.iso >> C:\ExtractLog.txt
Write-BuildLog "VMware Tools V6.0 Downloaded and extracted to build share."
}
60 { 60 {
B:\Automate\_Common\wget.exe -nd http://packages.vmware.com/tools/esx/6.0/windows/VMware-tools-windows-9.10.0-2476743.iso --no-check-certificate -awget.log B:\Automate\_Common\wget.exe -nd http://packages.vmware.com/tools/esx/6.0/windows/VMware-tools-windows-9.10.0-2476743.iso --no-check-certificate -awget.log
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VMtools\ c:\temp\VMware-tools-windows-9.10.0-2476743.iso >> C:\ExtractLog.txt . "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VMtools\ c:\temp\VMware-tools-windows-9.10.0-2476743.iso >> C:\ExtractLog.txt
@ -582,15 +722,15 @@ if (Test-Path -Path "B:\VMTools\setup*") {
} }
} }
if (Test-Path -Path "B:\VMTools\setup*") { if (Test-Path -Path "B:\VMTools\setup*") {
Write-BuildLog "VMware Tools found." Write-BuildLog "VMware Tools found."
$vmtools = $true $vmtools = $true
} }
Write-BuildLog ""
} }
if (($vmtools) -and (-Not (Test-Path "C:\Program Files\VMware\VMware Tools\VMwareToolboxCmd.exe"))) { if (($vmtools) -and (-Not (Test-Path "C:\Program Files\VMware\VMware Tools\VMwareToolboxCmd.exe"))) {
Write-BuildLog "Installing VMware tools, build complete after reboot." Write-BuildLog "Installing VMware tools, build complete after reboot."
Write-BuildLog "(Re)build vCenter next." Write-BuildLog "(Re)build vCenter next."
if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none")){ if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none")){
Write-BuildLog "Emailing log"
$mailmessage = New-Object system.net.mail.mailmessage $mailmessage = New-Object system.net.mail.mailmessage
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25) $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$mailmessage.from = "AutoLab<autolab@labguides.com>" $mailmessage.from = "AutoLab<autolab@labguides.com>"
@ -603,6 +743,8 @@ if (($vmtools) -and (-Not (Test-Path "C:\Program Files\VMware\VMware Tools\VMwar
$attach = new-object Net.Mail.Attachment("C:\buildlog.txt") $attach = new-object Net.Mail.Attachment("C:\buildlog.txt")
$mailmessage.Attachments.Add($attach) $mailmessage.Attachments.Add($attach)
$SMTPClient.Send($mailmessage) $SMTPClient.Send($mailmessage)
$mailmessage.dispose()
$SMTPClient.dispose()
} }
Start-Process B:\VMTools\setup64.exe -ArgumentList '/s /v "/qn"' -verb RunAs -Wait Start-Process B:\VMTools\setup64.exe -ArgumentList '/s /v "/qn"' -verb RunAs -Wait
Start-Sleep -Seconds 300 Start-Sleep -Seconds 300

View File

@ -7,7 +7,7 @@ LABEL Main Menu
label esx50 label esx50
KERNEL /esxi50/mboot.c32 KERNEL /esxi50/mboot.c32
APPEND -c /esxi50/boot.cfg APPEND -c /esxi50/bootm.cfg
MENU LABEL ESXi 5.0 Manual Install MENU LABEL ESXi 5.0 Manual Install
label esx1-5 label esx1-5

View File

@ -7,7 +7,7 @@ LABEL Main Menu
label esx51 label esx51
KERNEL /esxi51/mboot.c32 KERNEL /esxi51/mboot.c32
APPEND -c /esxi51/boot.cfg APPEND -c /esxi51/bootm.cfg
MENU LABEL ESXi 5.1 Manual Install MENU LABEL ESXi 5.1 Manual Install
label ESX1-5 label ESX1-5

View File

@ -7,7 +7,7 @@ LABEL Main Menu
label esx51 label esx51
KERNEL /esxi55/mboot.c32 KERNEL /esxi55/mboot.c32
APPEND -c /esxi55/boot.cfg APPEND -c /esxi55/bootm.cfg
MENU LABEL ESXi 5.5 Manual Install MENU LABEL ESXi 5.5 Manual Install
label ESX1-5 label ESX1-5

View File

@ -7,7 +7,7 @@ LABEL Main Menu
label esx51 label esx51
KERNEL /esxi60/mboot.c32 KERNEL /esxi60/mboot.c32
APPEND -c /esxi60/boot.cfg APPEND -c /esxi60/bootm.cfg
MENU LABEL ESXi 6.0 Manual Install MENU LABEL ESXi 6.0 Manual Install
label ESX1-5 label ESX1-5

View File

@ -0,0 +1,31 @@
MENU TITLE ESXi 6.5 installs
LABEL Main Menu
MENU LABEL ^Return to Main Menu
KERNEL pxelinux.cfg/menu.c32
APPEND pxelinux.cfg/default
label esx51
KERNEL /esxi65/mboot.c32
APPEND -c /esxi65/bootm.cfg
MENU LABEL ESXi 6.5 Manual Install
label ESX1-5
KERNEL /esxi65/mboot.c32
APPEND -c /esxi65/Besx1-65.cfg
MENU LABEL Host1 Automated Install
Label ESX2-5
KERNEL /esxi65/mboot.c32
APPEND -c /esxi65/Besx2-65.cfg
MENU LABEL Host2 Automated Install
Label ESX3-5
KERNEL /esxi65/mboot.c32
APPEND -c /esxi65/Besx3-65.cfg
MENU LABEL Host3 Automated Install
Label ESX4-5
KERNEL /esxi65/mboot.c32
APPEND -c /esxi65/Besx4-65.cfg
MENU LABEL Host4 Automated Install

View File

@ -0,0 +1,31 @@
MENU TITLE ESXi 6.7 installs
LABEL Main Menu
MENU LABEL ^Return to Main Menu
KERNEL pxelinux.cfg/menu.c32
APPEND pxelinux.cfg/default
label esx51
KERNEL /esxi67/mboot.c32
APPEND -c /esxi67/bootm.cfg
MENU LABEL ESXi 6.7 Manual Install
label ESX1-5
KERNEL /esxi67/mboot.c32
APPEND -c /esxi67/Besx1-67.cfg
MENU LABEL Host1 Automated Install
Label ESX2-5
KERNEL /esxi67/mboot.c32
APPEND -c /esxi67/Besx2-67.cfg
MENU LABEL Host2 Automated Install
Label ESX3-5
KERNEL /esxi67/mboot.c32
APPEND -c /esxi67/Besx3-67.cfg
MENU LABEL Host3 Automated Install
Label ESX4-5
KERNEL /esxi67/mboot.c32
APPEND -c /esxi67/Besx4-67.cfg
MENU LABEL Host4 Automated Install

View File

@ -1,22 +1,86 @@
# Functions used in AutoLab PowerShell scripts # Functions used in AutoLab PowerShell scripts
# #
# #
# Version 2.6 # Version 3.0
# #
# This Function from the PowerCLI Blog function browserAndFlash {
# http://blogs.vmware.com/vipowershell/2009/08/how-to-list-datastores-that-are-on-shared-storage.html if ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62) {
# Write-BuildLog "Install Firefox browser"
start-process "B:\automate\_common\Firefox Setup 59.0.3.exe" -ArgumentList " -ms" -Wait -Verb RunAs
do {
start-sleep 10
} until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null)
Write-BuildLog "Installing Adobe Flash Player."
Start-Process msiexec -ArgumentList '/i b:\Automate\_Common\install_flash_player_29_plugin.msi /qb' -Wait
do {
start-sleep 10
} until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null)
}
}
Function deployPowerCLI {
Write-BuildLog "Installing PowerCLI"
$PCLIver = 0
if ((Test-Path "b:\VMware-PowerCLI-6.7.*.exe") -and ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)) {
Write-BuildLog "VMware PowerCLI 6.7 installer found; installing."
$PCLIver = 67
Start-Process (Get-ChildItem b:\VMware-PowerCLI-6.7.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} elseif ((Test-Path "b:\VMware-PowerCLI-6.5.*.exe") -and ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)) {
Write-BuildLog "VMware PowerCLI 6.5 installer found; installing."
$PCLIver = 65
Start-Process (Get-ChildItem b:\VMware-PowerCLI-6.5.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} elseif ((Test-Path "b:\VMware-PowerCLI-6.3.*.exe") -and ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)) {
Write-BuildLog "VMware PowerCLI 6.3 installer found; installing."
$PCLIver = 63
Start-Process (Get-ChildItem b:\VMware-PowerCLI-6.3.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} elseif ((Test-Path "b:\VMware-PowerCLI-6.0.*.exe") -and ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)) {
Write-BuildLog "VMware PowerCLI 6.0 installer found; installing."
$PCLIver = 60
Start-Process (Get-ChildItem b:\VMware-PowerCLI-6.0.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} elseif (Test-Path "b:\VMware-PowerCLI-5.8.*.exe") {
Write-BuildLog "VMware PowerCLI 5.8 installer found; installing."
$PCLIver = 58
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.8.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} elseif (Test-Path "b:\VMware-PowerCLI-5.5.*.exe") {
Write-BuildLog "VMware PowerCLI 5.5 installer found; installing."
$PCLIver = 55
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.5.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} elseif (Test-Path "b:\VMware-PowerCLI-5.0.*.exe"){
Write-BuildLog "VMware PowerCLI 5.0 installer found; installing."
$PCLIver = 50
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.0.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} else {
If ((Read-Host "Would you like to go to the PowerCLI download site (y/n)?") -like "y") {
$IE=new-object -com internetexplorer.application
if ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62) {$IE.navigate2("https://my.vmware.com/group/vmware/get-download?downloadGroup=PCLI670R1")}
if ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -lt 62) {$IE.navigate2("https://my.vmware.com/group/vmware/get-download?downloadGroup=PCLI58R1")}
$IE.visible=$true
} Else {
Write-Host "OK, but the build will not work correctly without PowerCLI"
}
}
Write-BuildLog "Add PowerCLI $PCLIver initialization to PowerShell environment"
$null = New-Item -ItemType directory -Path "C:\Users\administrator\Documents\WindowsPowerShell\"
$null = New-Item -ItemType directory -Path "C:\Users\Default\Documents\WindowsPowerShell\"
$null = Copy-Item "B:\automate\_common\profile.ps1" -Destination "C:\Users\administrator\Documents\WindowsPowerShell\"
$null = Copy-Item "B:\automate\_common\profile.ps1" -Destination "C:\Users\Default\Documents\WindowsPowerShell"
return $PCLIver
}
function Write-BuildLog { function Write-BuildLog {
param([string]$message) param([string]$message)
if (!(Test-Path C:\Buildlog.txt)) { if (!(Test-Path C:\Buildlog.txt)) {
New-Item -Path C:\Buildlog.txt -ItemType File New-Item -Path C:\Buildlog.txt -ItemType File
} }
Write-Host $message $out = (get-date -f HH:mm:ss) + " " + $message
$message | Out-File C:\BuildLog.txt -Encoding Default -append Write-Host $out
$out | Out-File C:\BuildLog.txt -Encoding Default -append
} }
# This Function from the PowerCLI Blog
# http://blogs.vmware.com/vipowershell/2009/08/how-to-list-datastores-that-are-on-shared-storage.html
#
function Get-ShareableDatastore { function Get-ShareableDatastore {
# Get all datastores. # Get all datastores.
$datastores = Get-Datastore $datastores = Get-Datastore
@ -82,7 +146,7 @@ Function Check-File ($a, $b) {
if (test-Path $a) { if (test-Path $a) {
Write-Host ($b + " found.") -foregroundcolor "green" Write-Host ($b + " found.") -foregroundcolor "green"
} else { } else {
Write-Host ($b + " missing.") -foregroundcolor "red" Write-Host ("**** " + $b + " missing.") -foregroundcolor "red"
$Global:Pass = $False $Global:Pass = $False
} }
} }
@ -91,7 +155,7 @@ Function Check-OptionalFile ($a, $b) {
if (test-Path $a) { if (test-Path $a) {
Write-Host ($b + " found.") -foregroundcolor "green" Write-Host ($b + " found.") -foregroundcolor "green"
} else { } else {
Write-Host ($b + " missing.") -foregroundcolor "Yellow" Write-Host ("**** " + $b + " missing.") -foregroundcolor "Yellow"
} }
} }
@ -100,7 +164,7 @@ Function Check-ServiceRunning ($a) {
if ($SVC.Status -eq "Running") { if ($SVC.Status -eq "Running") {
Write-Host ("Service " + $a + " running.") -foregroundcolor "green" Write-Host ("Service " + $a + " running.") -foregroundcolor "green"
} else { } else {
Write-Host ("Service " + $a + " not running.") -foregroundcolor "red" Write-Host ("**** Service " + $a + " not running.") -foregroundcolor "red"
$Global:Pass = $False $Global:Pass = $False
} }
} }
@ -111,7 +175,7 @@ Function Check-DNSRecord ($a) {
$FWDIP = [System.Net.Dns]::GetHostAddresses($a) $FWDIP = [System.Net.Dns]::GetHostAddresses($a)
$ErrorActionPreference = "continue" $ErrorActionPreference = "continue"
if ($FWDIP -eq "") { if ($FWDIP -eq "") {
Write-Host ("No DNS for " + $a ) -foregroundcolor "red" Write-Host ("**** No DNS for " + $a ) -foregroundcolor "red"
$Global:Pass = $False $Global:Pass = $False
} else { } else {
Write-Host ("DNS OK for " + $a) -foregroundcolor "green" Write-Host ("DNS OK for " + $a) -foregroundcolor "green"

View File

@ -22,9 +22,37 @@ param($version)
. "C:\PSFunctions.ps1" . "C:\PSFunctions.ps1"
switch ($version) { switch ($version) {
ESXi67 {
if ((Test-Path "C:\TFTP-Root\ESXi67\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\default" | Select-String -Pattern "ESXi 6.7"))) {
Write-BuildLog "Adding ESXi 6.7 option to PXE menu"
Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @"
LABEL ESXi 67
MENU LABEL ESXi 6.7 automated builds
KERNEL pxelinux.cfg/menu.c32
APPEND pxelinux.cfg/ESXi67.menu
"@
} else {
Write-BuildLog "ESXi 6.7 already in PXE Menu"
}
}
ESXi65 {
if ((Test-Path "C:\TFTP-Root\ESXi65\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\default" | Select-String -Pattern "ESXi 6.5"))) {
Write-BuildLog "Adding ESXi 6.5 option to PXE menu"
Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @"
LABEL ESXi 65
MENU LABEL ESXi 6.5 automated builds
KERNEL pxelinux.cfg/menu.c32
APPEND pxelinux.cfg/ESXi65.menu
"@
} else {
Write-BuildLog "ESXi 6.5 already in PXE Menu"
}
}
ESXi60 { ESXi60 {
if ((Test-Path "C:\TFTP-Root\ESXi60\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\default" | Select-String -Pattern "ESXi 6.0"))) { if ((Test-Path "C:\TFTP-Root\ESXi60\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\default" | Select-String -Pattern "ESXi 6.0"))) {
Add-Content -Path "C:\buildlog.txt" -Value "Adding ESXi 6.0 option to PXE menu" Write-BuildLog "Adding ESXi 6.0 option to PXE menu"
Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @" Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @"
LABEL ESXi 60 LABEL ESXi 60
@ -33,12 +61,12 @@ LABEL ESXi 60
APPEND pxelinux.cfg/ESXi60.menu APPEND pxelinux.cfg/ESXi60.menu
"@ "@
} else { } else {
Write-BuildLog "ESXi 5.5 already in PXE Menu" Write-BuildLog "ESXi 6.0 already in PXE Menu"
} }
} }
ESXi55 { ESXi55 {
if ((Test-Path "C:\TFTP-Root\ESXi55\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\default" | Select-String -Pattern "ESXi 5.5"))) { if ((Test-Path "C:\TFTP-Root\ESXi55\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\default" | Select-String -Pattern "ESXi 5.5"))) {
Add-Content -Path "C:\buildlog.txt" -Value "Adding ESXi 5.5 option to PXE menu" Write-BuildLog "Adding ESXi 5.5 option to PXE menu"
Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @" Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @"
LABEL ESXi 5.5 LABEL ESXi 5.5
@ -52,7 +80,7 @@ LABEL ESXi 5.5
} }
ESXi51 { ESXi51 {
if ((Test-Path "C:\TFTP-Root\ESXi51\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\default" | Select-String -Pattern "ESXi 5.1"))) { if ((Test-Path "C:\TFTP-Root\ESXi51\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\default" | Select-String -Pattern "ESXi 5.1"))) {
Add-Content -Path "C:\buildlog.txt" -Value "Adding ESXi 5.1 option to PXE menu" Write-BuildLog "Adding ESXi 5.1 option to PXE menu"
Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @" Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @"
LABEL ESXi 5.1 LABEL ESXi 5.1
@ -66,7 +94,7 @@ LABEL ESXi 5.1
} }
ESXi50 { ESXi50 {
if ((Test-Path "C:\TFTP-Root\ESXi50\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\default" | Select-String -Pattern "ESXi 5.0"))) { if ((Test-Path "C:\TFTP-Root\ESXi50\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\default" | Select-String -Pattern "ESXi 5.0"))) {
Add-Content -Path "C:\buildlog.txt" -Value "Adding ESXi 5.0 option to PXE menu" Write-BuildLog "Adding ESXi 5.0 option to PXE menu"
Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @" Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @"
LABEL ESXi 5.0 LABEL ESXi 5.0
@ -78,7 +106,7 @@ LABEL ESXi 5.0
} }
ESXi41 { ESXi41 {
if (Test-Path "C:\TFTP-Root\ESXi41\*") { if (Test-Path "C:\TFTP-Root\ESXi41\*") {
Add-Content -Path "C:\buildlog.txt" -Value "Adding ESXi 4.1 option to PXE menu" Write-BuildLog "Adding ESXi 4.1 option to PXE menu"
Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @" Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @"
LABEL ESXi 4.1 LABEL ESXi 4.1
@ -102,7 +130,7 @@ label esxi2-4
} }
ESX41 { ESX41 {
if ((Test-Path "C:\TFTP-Root\ESX41\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\ESXi41.menu" | Select-String -Pattern "ESX classic"))) { if ((Test-Path "C:\TFTP-Root\ESX41\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\ESXi41.menu" | Select-String -Pattern "ESX classic"))) {
Add-Content -Path "C:\buildlog.txt" -Value "Adding ESX 4.1 option to PXE menu" Write-BuildLog "Adding ESX 4.1 option to PXE menu"
Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\ESXi41.menu" -Value @" Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\ESXi41.menu" -Value @"
label esx2-4 label esx2-4
@ -114,7 +142,7 @@ label esx2-4
} }
vCloud { vCloud {
if (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\default" | Select-String -Pattern "vCloud") ) { if (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\default" | Select-String -Pattern "vCloud") ) {
Add-Content -Path "C:\buildlog.txt" -Value "Adding vCloud option to PXE menu" Write-BuildLog "Adding vCloud option to PXE menu"
Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @" Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\default" -Value @"
LABEL vCloud LABEL vCloud
@ -126,7 +154,7 @@ LABEL vCloud
} }
vCD51 { vCD51 {
if ((Test-Path "B:\vCD_51\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\vCloud.menu" | Select-String -Pattern "vCloud Director 5.1"))){ if ((Test-Path "B:\vCD_51\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\vCloud.menu" | Select-String -Pattern "vCloud Director 5.1"))){
Add-Content -Path "C:\buildlog.txt" -Value "Adding vCloud 5.1 option to PXE menu" Write-BuildLog "Adding vCloud 5.1 option to PXE menu"
Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\vCloud.menu" -Value @" Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\vCloud.menu" -Value @"
label vCloud51 label vCloud51
@ -143,7 +171,7 @@ label vCloud51
} }
vCD15 { vCD15 {
if ((Test-Path "B:\vCD_15\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\vCloud.menu" | Select-String -Pattern "vCloud Director 1.5"))){ if ((Test-Path "B:\vCD_15\*") -and (!(Get-Content "C:\TFTP-Root\pxelinux.cfg\vCloud.menu" | Select-String -Pattern "vCloud Director 1.5"))){
Add-Content -Path "C:\buildlog.txt" -Value "Adding vCloud 1.5 option to PXE menu" Write-BuildLog "Adding vCloud 1.5 option to PXE menu"
Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\vCloud.menu" -Value @" Add-Content -Path "C:\TFTP-Root\pxelinux.cfg\vCloud.menu" -Value @"
label vCloud15 label vCloud15

View File

@ -1,10 +1,12 @@
@echo off @echo off
echo ************************* echo *************************
echo * echo *
echo ** echo * Begining Build.cmd as %userdomain%\%username%
echo * Begining Build.cmd as %userdomain%\%username% >> c:\buildlog.txt
echo * Connect to build share echo * Connect to build share
net use B: \\192.168.199.7\Build >> c:\buildlog.txt echo * Connect to build share >> c:\buildlog.txt
type b:\automate\version.txt >> c:\buildlog.txt if not exist B:\ net use B: \\192.168.199.7\Build
if not exist c:\temp\ md c:\temp
regedit -s b:\Automate\_Common\ExecuPol.reg regedit -s b:\Automate\_Common\ExecuPol.reg
regedit -s b:\Automate\_Common\NoSCRNSave.reg regedit -s b:\Automate\_Common\NoSCRNSave.reg
regedit -s B:\Automate\_Common\ExplorerView.reg regedit -s B:\Automate\_Common\ExplorerView.reg
@ -12,9 +14,11 @@ regedit -s b:\Automate\_Common\IExplorer.reg
REG ADD "HKCU\Environment" /V SEE_MASK_NOZONECHECKS /T REG_SZ /D 1 /F REG ADD "HKCU\Environment" /V SEE_MASK_NOZONECHECKS /T REG_SZ /D 1 /F
REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V SEE_MASK_NOZONECHECKS /T REG_SZ /D 1 /F REG ADD "HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment" /V SEE_MASK_NOZONECHECKS /T REG_SZ /D 1 /F
REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments " /V SaveZoneInformation /T REG_SZ /D 1 /F REG ADD "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments " /V SaveZoneInformation /T REG_SZ /D 1 /F
copy B:\automate\_Common\wasp.dll C:\windows\system32
echo * Activate Windows >> c:\buildlog.txt echo * Activate Windows >> c:\buildlog.txt
cscript //B "%windir%\system32\slmgr.vbs" /ato cscript //B "%windir%\system32\slmgr.vbs" /ato
copy B:\Automate\PSFunctions.ps1 C:\ copy B:\Automate\PSFunctions.ps1 C:\
copy B:\Automate\validate.ps1 C:\
copy B:\Automate\%computername%\Build.ps1 c:\ copy B:\Automate\%computername%\Build.ps1 c:\
echo * Starting PowerShell script for Phase 2 completion echo * Starting PowerShell script for Phase 2 completion
echo * Starting PowerShell script for Phase 2 completion >> C:\buildlog.txt echo * Starting PowerShell script for Phase 2 completion >> C:\buildlog.txt

View File

@ -5,6 +5,13 @@ if (Test-Path C:\PSFunctions.ps1) {
Read-Host "Press <Enter> to exit" Read-Host "Press <Enter> to exit"
exit exit
} }
$a = (Get-Host).UI.RawUI
$a.WindowTitle = "SS Build Automation"
$b = $a.WindowSize
$b.Height = $a.MaxWindowSize.Height - 1
$a.WindowSize = $b
Import-Module C:\windows\system32\WASP.dll
Select-Window -Title "SS Build Automation" | set-windowposition -left 75 -top 3
if (Test-Path "B:\Automate\automate.ini") { if (Test-Path "B:\Automate\automate.ini") {
Write-BuildLog "Determining automate.ini settings." Write-BuildLog "Determining automate.ini settings."
@ -17,6 +24,26 @@ if (Test-Path "B:\Automate\automate.ini") {
$emailto = ((Select-String -SimpleMatch "emailto=" -Path "B:\Automate\automate.ini").line).substring(8) $emailto = ((Select-String -SimpleMatch "emailto=" -Path "B:\Automate\automate.ini").line).substring(8)
$SmtpServer = ((Select-String -SimpleMatch "SmtpServer=" -Path "B:\Automate\automate.ini").line).substring(11) $SmtpServer = ((Select-String -SimpleMatch "SmtpServer=" -Path "B:\Automate\automate.ini").line).substring(11)
} }
if ((Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain -eq $False) {
Write-BuildLog "Joining domain"
B:\automate\_Common\Autologon administrator lab $AdminPWD
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f
$password = $AdminPWD | ConvertTo-SecureString -asPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential("administrator",$password)
$null = Add-Computer -DomainName "lab.local" -Credential $credential -restart
read-host "Wait for restart"
} else {
regedit /s b:\Automate\_Common\ExecuPol.reg
regedit -s b:\Automate\_Common\NoSCRNSave.reg
Write-BuildLog "Change default local administrator password"
net user administrator $AdminPWD
B:\automate\_Common\Autologon administrator lab $AdminPWD
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f
Write-BuildLog "Setup Firewall"
netsh advfirewall firewall add rule name="All ICMP V4" dir=in action=allow protocol=icmpv4
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
}
If (([System.Environment]::OSVersion.Version.Major -eq 6) -and ([System.Environment]::OSVersion.Version.Minor -ge 2)) { If (([System.Environment]::OSVersion.Version.Major -eq 6) -and ([System.Environment]::OSVersion.Version.Minor -ge 2)) {
Write-BuildLog "Disabling autorun of ServerManager at logon." Write-BuildLog "Disabling autorun of ServerManager at logon."
Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs
@ -38,51 +65,43 @@ Switch ($ViewInstall) {
Write-BuildLog "Install View 5.0 Security Server" Write-BuildLog "Install View 5.0 Security Server"
copy $Installer C:\ViewInstaller.exe copy $Installer C:\ViewInstaller.exe
Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=SS.external.com VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.20.199 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172"' Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=SS.external.com VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.20.199 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172"'
} } 51 {
51 {
Write-BuildLog "Install View 5.1 Security Server" Write-BuildLog "Install View 5.1 Security Server"
copy $Installer C:\ViewInstaller.exe copy $Installer C:\ViewInstaller.exe
Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=SS.external.com VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.20.199 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172"' Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=SS.external.com VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.20.199 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172"'
} } 52 {
52 {
Write-BuildLog "Install View 5.2 Security Server" Write-BuildLog "Install View 5.2 Security Server"
copy $Installer C:\ViewInstaller.exe copy $Installer C:\ViewInstaller.exe
Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=SS.external.com VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.20.199 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172"' Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=SS.external.com VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.20.199 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172"'
} } 53 {
53 {
Write-BuildLog "Install View 5.3 Security Server" Write-BuildLog "Install View 5.3 Security Server"
copy $Installer C:\ViewInstaller.exe copy $Installer C:\ViewInstaller.exe
Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=SS.external.com VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.20.199 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172"' Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=SS.external.com VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.20.199 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172"'
} } 60 {
60 {
Write-BuildLog "Install View 6.0 Security Server" Write-BuildLog "Install View 6.0 Security Server"
copy $Installer C:\ViewInstaller.exe copy $Installer C:\ViewInstaller.exe
Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=https://SS.lab.local:443 VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.199.35 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172"' Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=https://SS.lab.local:443 VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.199.35 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172"'
} } 70 {
70 {
Write-BuildLog "Install View 7.0 Security Server" Write-BuildLog "Install View 7.0 Security Server"
copy $Installer C:\ViewInstaller.exe copy $Installer C:\ViewInstaller.exe
Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=https://SS.lab.local:443 VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.199.35 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172"' -verb RunAs Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=https://SS.lab.local:443 VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.199.35 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172"' -verb RunAs
} 75 {
Write-BuildLog "Install View 7.5 Security Server"
copy $Installer C:\ViewInstaller.exe
Start-Process C:\ViewInstaller.exe -wait -ArgumentList '/s /v"/qn VDM_SERVER_INSTANCE_TYPE=3 VDM_SERVER_NAME=cs1.lab.local VDM_SERVER_SS_EXTURL=https://SS.lab.local:443 VDM_SERVER_SS_PWD=VMware1! VDM_SERVER_SS_PCOIP_IPADDR=192.168.199.35 VDM_SERVER_SS_PCOIP_TCPPORT=4172 VDM_SERVER_SS_PCOIP_UDPPORT=4172 VDM_IP_PROTOCOL_USAG=IPv4"' -verb RunAs
} }
} }
Write-BuildLog "Install Flash Player"
Start-Process msiexec -wait -ArgumentList " /i b:\Automate\_Common\install_flash_player_11_active_x.msi /qn" browserAndFlash
Write-BuildLog "Setup Firewall"
netsh advfirewall firewall add rule name="All ICMP V4" dir=in action=allow protocol=icmpv4
netsh advfirewall firewall set rule group="remote desktop" new enable=Yes
netsh advfirewall firewall set rule group="File and Printer Sharing" new enable=Yes
Write-BuildLog "Setup persistet route to other subnet for SRM and View"
route add 192.168.201.0 mask 255.255.255.0 192.168.199.254 -p
Write-BuildLog "Cleanup" Write-BuildLog "Cleanup"
regedit /s b:\Automate\_Common\ExecuPol.reg regedit /s b:\Automate\_Common\ExecuPol.reg
regedit -s b:\Automate\_Common\NoSCRNSave.reg regedit -s b:\Automate\_Common\NoSCRNSave.reg
Write-BuildLog "Change default local administrator password"
net user administrator $AdminPWD
B:\automate\_Common\Autologon vi-admin lab $AdminPWD
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f
Write-BuildLog "Install VMware Tools" Write-BuildLog "Install VMware Tools"
b:\VMTools\Setup64.exe /s /v "/qn" b:\VMTools\Setup64.exe /s /v "/qn"
if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none")){ if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none")){
Write-BuildLog "Emailing log"
$mailmessage = New-Object system.net.mail.mailmessage $mailmessage = New-Object system.net.mail.mailmessage
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25) $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$mailmessage.from = "AutoLab<autolab@labguides.com>" $mailmessage.from = "AutoLab<autolab@labguides.com>"
@ -95,5 +114,7 @@ if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none"))
$attach = new-object Net.Mail.Attachment("C:\buildlog.txt") $attach = new-object Net.Mail.Attachment("C:\buildlog.txt")
$mailmessage.Attachments.Add($attach) $mailmessage.Attachments.Add($attach)
$SMTPClient.Send($mailmessage) $SMTPClient.Send($mailmessage)
$mailmessage.dispose()
$SMTPClient.dispose()
} }
Read-Host "Rebooting after VMTools Install" Read-Host "Rebooting after VMTools Install"

Binary file not shown.

Binary file not shown.

View File

@ -1,12 +1,12 @@
@echo off @echo off
echo ************************* echo *************************
echo * echo *
echo ** echo * Begining Build.cmd as %userdomain%\%username%
echo * Begining Build.cmd as %userdomain%\%username% >> c:\buildlog.txt
echo * Connect to build share echo * Connect to build share
echo * Connect to build share >> c:\buildlog.txt echo * Connect to build share >> c:\buildlog.txt
net use B: \\192.168.199.7\Build >> c:\buildlog.txt if not exist B:\ net use B: \\192.168.199.7\Build
md c:\temp if not exist c:\temp\ md c:\temp
type b:\automate\version.txt >> c:\buildlog.txt
regedit -s b:\Automate\_Common\ExecuPol.reg regedit -s b:\Automate\_Common\ExecuPol.reg
regedit -s b:\Automate\_Common\NoSCRNSave.reg regedit -s b:\Automate\_Common\NoSCRNSave.reg
regedit -s B:\Automate\_Common\ExplorerView.reg regedit -s B:\Automate\_Common\ExplorerView.reg
@ -17,10 +17,9 @@ copy B:\Automate\validate.ps1 C:\
copy B:\Automate\PSFunctions.ps1 C:\ copy B:\Automate\PSFunctions.ps1 C:\
copy B:\Automate\VC\Build.ps1 c:\ copy B:\Automate\VC\Build.ps1 c:\
copy B:\Automate\VC\Derek-SSL.ps1 c:\ copy B:\Automate\VC\Derek-SSL.ps1 c:\
copy B:\automate\_Common\wasp.dll C:\windows\system32
echo * Activate Windows >> c:\buildlog.txt echo * Activate Windows >> c:\buildlog.txt
cscript //B "%windir%\system32\slmgr.vbs" /ato cscript //B "%windir%\system32\slmgr.vbs" /ato
echo * Starting PowerShell script for Build echo * Starting PowerShell script for Build
echo * Starting PowerShell script for Build >> C:\buildlog.txt echo * Starting PowerShell script for Build >> C:\buildlog.txt
powershell c:\Build.ps1 powershell c:\Build.ps1
if exist C:\Build.ps1 del c:\Build.ps1
if exist C:\Build.cmd del c:\Build.cmd

View File

@ -5,6 +5,14 @@ if (Test-Path C:\PSFunctions.ps1) {
Read-Host "Press <Enter> to exit" Read-Host "Press <Enter> to exit"
exit exit
} }
write-buildlog "Starting Build.ps1"
$a = (Get-Host).UI.RawUI
$a.WindowTitle = "VC Build Automation"
$b = $a.WindowSize
$b.Height = $a.MaxWindowSize.Height - 1
$a.WindowSize = $b
Import-Module C:\windows\system32\WASP.dll
Select-Window -Title "VC Build Automation" | set-windowposition -left 75 -top 3
# Start VC configuration process # Start VC configuration process
if (Test-Path "B:\Automate\automate.ini") { if (Test-Path "B:\Automate\automate.ini") {
@ -99,97 +107,129 @@ if (Test-Path "B:\Automate\automate.ini") {
} else { } else {
Write-BuidLog "Unable to find B:\Automate\automate.ini. Where did it go?" Write-BuidLog "Unable to find B:\Automate\automate.ini. Where did it go?"
} }
if ((Get-WmiObject -Class Win32_ComputerSystem).PartOfDomain -eq $False) {
Write-BuildLog "Joining domain"
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f
$password = $AdminPWD | ConvertTo-SecureString -asPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential("administrator",$password)
$null = Add-Computer -DomainName "lab.local" -Credential $credential -restart
read-host "Waiting for restart"
} else {
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f
}
Write-BuildLog "Clear System eventlog, errors to here are spurious"
Clear-EventLog -LogName System -confirm:$False
If ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62) { If ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62) {
Write-BuildLog "Disabling autorun of ServerManager at logon." Write-BuildLog "Disabling autorun of ServerManager at logon."
Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs
Write-BuildLog "Disabling screen saver" Write-BuildLog "Disabling screen saver"
set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0 set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0
} }
if (Test-Path "C:\VMware-viewcomposer*") {
$Files = get-childitem "C:\"
for ($i=0; $i -lt $files.Count; $i++) {
If ($Files[$i].Name -like "VMware-viewcomposer*") {$Installer = $Files[$i].FullName}
}
switch ($viewinstall) {
70 {
Write-BuildLog "Installing VMware View 7.0 Composer"
Start-Process $Installer -ArgumentList '/s /v" /qn AgreeToLicense="Yes" DB_USERNAME="VMview" DB_PASSWORD="VMware1!" DB_DSN="ViewComposer" REBOOT="ReallySuppress" "' -Wait -Verb RunAs
} 60 {
Write-BuildLog "Installing VMware View 6.0 Composer"
Start-Process $Installer -ArgumentList '/s /v" /qn AgreeToLicense="Yes" DB_USERNAME="VMview" DB_PASSWORD="VMware1!" DB_DSN="ViewComposer" REBOOT="ReallySuppress" "' -Wait -Verb RunAs
} 53 {
Write-BuildLog "Installing VMware View 5.3 Composer"
Start-Process $Installer -ArgumentList '/s /v" /qn AgreeToLicense="Yes" DB_USERNAME="VMview" DB_PASSWORD="VMware1!" DB_DSN="ViewComposer" REBOOT="ReallySuppress" "' -Wait -Verb RunAs
} 52 {
Write-BuildLog "Installing VMware View 5.2 Composer"
Start-Process $Installer -ArgumentList '/s /v" /qn AgreeToLicense="Yes" DB_USERNAME="VMview" DB_PASSWORD="VMware1!" DB_DSN="ViewComposer" REBOOT="ReallySuppress" "' -Wait -Verb RunAs
}
}
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f
Exit
}
Write-BuildLog "Clear System eventlog, erors to here are spurious"
Clear-EventLog -LogName System -confirm:$False
Write-BuildLog "Installing 7-zip." Write-BuildLog "Installing 7-zip."
try { Start-Process msiexec -ArgumentList '/qb /i B:\Automate\_Common\7z1805-x64.msi' -Wait
Start-Process msiexec -ArgumentList '/qb /i B:\Automate\_Common\7z920-x64.msi' -Wait do {
} start-sleep 10
catch { } until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null)
Write-BuildLog "7-zip installation failed."
}
Write-BuildLog "Installing PuTTy." Write-BuildLog "Installing PuTTy."
$null = New-Item -Path "C:\Program Files (x86)\PuTTY" -ItemType Directory -Force $null = New-Item -Path "C:\Program Files (x86)\PuTTY" -ItemType Directory -Force
xcopy B:\Automate\vc\PuTTY\*.* "C:\Program Files (x86)\PuTTY" /s /c /y /q xcopy B:\Automate\vc\PuTTY\*.* "C:\Program Files (x86)\PuTTY" /s /c /y /q
regedit -s B:\Automate\vc\PuTTY.reg regedit -s B:\Automate\vc\PuTTY.reg
If (!((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)) {
try {
Write-BuildLog "Installing Adobe Flash Player."
Start-Process msiexec -ArgumentList '/i b:\Automate\_Common\install_flash_player_17_active_x.msi /qb' -Wait
}
catch {
Write-BuildLog "Adobe Flash Player installation failed."
}
}
Write-BuildLog ""
#Install now running as local administrator, don't need to allow vi-admin access browserAndFlash
#$Acl = Get-Acl "C:\Buildlog.txt"
#$Ar = New-Object system.security.accesscontrol.filesystemaccessrule("lab\vi-admin","FullControl","Allow")
#$Acl.SetAccessRule($Ar)
#Set-Acl "C:\Buildlog.txt" $Acl
Write-BuildLog "Change default local administrator password" Write-BuildLog "Change default local administrator password"
net user administrator $AdminPWD net user administrator $AdminPWD
B:\automate\_Common\Autologon administrator vc $AdminPWD B:\automate\_Common\Autologon administrator vc $AdminPWD
Write-BuildLog ""
if (Test-Path "b:\VMware-PowerCLI*.exe") {
#Start-Process b:\VMware-PowerCLI.exe -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
$null = New-Item -Path "C:\Users\vi-admin\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1" -ItemType File -Force
$null = Add-Content -Path "C:\Users\vi-admin\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1" -Value @"
if ((Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq `$null) {
try {
Write-Host "Loading PowerCLI plugin, this may take a little while." -foregroundcolor "cyan"
Add-PSSnapin VMware.VimAutomation.Core
`$PCLIVer = Get-PowerCLIVersion
if (((`$PCLIVer.Major * 10 ) + `$PCLIVer.Minor) -ge 51) {
`$null = Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -confirm:`$false -Scope "Session"
}
}
catch {
Write-Host "Unable to load the PowerCLI plugin. Please verify installation or install VMware PowerCLI and run this script again."
Read-Host "Press <Enter> to exit"
exit
}
}
"@
} else {
Write-BuildLog "VMware PowerCLI installer not found. This will need to be installing before running any AutoLab PowerShell post-install scripts."
}
switch ($vcinstall) { switch ($vcinstall) {
67 {
Write-BuildLog "Starting vCenter 6.7 automation."
If ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -eq 63) {
Write-BuildLog "Installing universal C Runtime for windows 2016"
B:
cd B:\VIM_67\
b:\automate\_common\wget.exe -q --no-check-certificate https://download.microsoft.com/download/D/1/3/D13E3150-3BB2-4B22-9D8A-47EE2D609FFF/Windows8.1-KB2999226-x64.msu
Start-Process wusa.exe -ArgumentList "B:\VIM_67\Windows8.1-KB2999226-x64.msu /quiet" -Wait -Verb RunAs
} ElseIf ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -eq 62) {
Write-BuildLog "Installing universal C Runtime for windows 2012"
B:
cd B:\VIM_67\
b:\automate\_common\wget.exe -q --no-check-certificate https://download.microsoft.com/download/9/3/E/93E0745A-EAE9-4B5A-B50C-012F2D3B6659/Windows8-RT-KB2999226-x64.msu
Start-Process wusa.exe -ArgumentList "B:\VIM_67\Windows8-RT-KB2999226-x64.msu /quiet" -Wait -Verb RunAs
} ElseIf ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -eq 61) {
Write-BuildLog "Installing universal C Runtime for windows 2008"
B:
cd B:\VIM_67\
b:\automate\_common\wget.exe -q --no-check-certificate https://download.microsoft.com/download/F/1/3/F13BEC9A-8FC6-4489-9D6A-F84BDC9496FE/Windows6.1-KB2999226-x64.msu
Start-Process wusa.exe -ArgumentList "B:\VIM_67\Windows6.1-KB2999226-x64.msu /quiet" -Wait -Verb RunAs
}
if (Test-Path "b:\VIM_67\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") {
Write-BuildLog "SQL Server 2012 Express SP1 for vCenter 6.7 found; installing."
Start-Process b:\VIM_67\redist\SQLEXPR\SQLEXPR_x64_ENU.exe -ArgumentList '/q /x:c:\temp /quiet' -Wait -Verb RunAs
if (Test-Path "C:\temp\pcusource\1033_enu_lp\x64\setup\x64\sqlncli.msi") {
copy C:\temp\pcusource\1033_enu_lp\x64\setup\x64\sqlncli.msi c:\temp
} elseif (Test-Path "C:\temp\1033_enu_lp\x64\setup\x64\sqlncli.msi") {
copy C:\temp\1033_enu_lp\x64\setup\x64\sqlncli.msi c:\temp
}
if (Test-Path "C:\temp\sqlncli.msi") {
Write-BuildLog "Installing SQL native client."
Start-Process msiexec -ArgumentList '/i C:\temp\sqlncli.msi ADDLOCAL=ALL IACCEPTSQLNCLILICENSETERMS=YES /qb' -Wait -Verb RunAs
Start-Process regedit -ArgumentList "-s B:\Automate\vc\vCenter6DB.reg" -Wait -Verb RunAs
do {
start-sleep 10
} until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null)
}
} else {
Write-BuildLog "SQL Server 2012 Express SP1 for vCenter 6.7 not found. Exiting."
Read-Host "Press <Enter> to exit"
exit
}
do {
start-sleep 10
} until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null)
Write-BuildLog "Installing vCentre server 6.7. with embedded PSC"
Start-Process B:\VIM_67\vCenter-Server\VMware-vCenter-Server.exe -ArgumentList " /qr CUSTOM_SETTINGS=B:\Automate\VC\vCentre60.json" -Wait -Verb RunAs
}
65 {
Write-BuildLog "Starting vCenter 6.5 automation."
if (Test-Path "b:\VIM_65\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") {
Write-BuildLog "SQL Server 2012 Express SP1 for vCenter 6.5 found; installing."
Start-Process b:\VIM_65\redist\SQLEXPR\SQLEXPR_x64_ENU.exe -ArgumentList '/q /x:c:\temp /quiet' -Wait -Verb RunAs
if (Test-Path "C:\temp\pcusource\1033_enu_lp\x64\setup\x64\sqlncli.msi") {
copy C:\temp\pcusource\1033_enu_lp\x64\setup\x64\sqlncli.msi c:\temp
} elseif (Test-Path "C:\temp\1033_enu_lp\x64\setup\x64\sqlncli.msi") {
copy C:\temp\1033_enu_lp\x64\setup\x64\sqlncli.msi c:\temp
}
if (Test-Path "C:\temp\sqlncli.msi") {
Write-BuildLog "Installing SQL native client."
Start-Process msiexec -ArgumentList '/i C:\temp\sqlncli.msi ADDLOCAL=ALL IACCEPTSQLNCLILICENSETERMS=YES /qb' -Wait -Verb RunAs
Start-Process regedit -ArgumentList "-s B:\Automate\vc\vCenter6DB.reg" -Wait -Verb RunAs
do {
start-sleep 10
} until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null)
}
} else {
Write-BuildLog "SQL Server 2012 Express SP1 for vCenter 6.5 not found. Exiting."
Read-Host "Press <Enter> to exit"
exit
}
Write-BuildLog "Installing vCentre server 6.5. with embedded PSC"
Start-Process B:\VIM_65\vCenter-Server\VMware-vCenter-Server.exe -ArgumentList " /qr CUSTOM_SETTINGS=B:\Automate\VC\vCentre60.json" -Wait -Verb RunAs
Write-BuildLog "Installing vCentre Client Integration Plugin"
If (!(Test-Path("c:\temp\VMware-ClientIntegrationPlugin-6.5.0.exe"))) {
B:
cd B:\VIM_65
B:\Automate\_Common\wget.exe -q http://vsphereclient.vmware.com/vsphereclient/VMware-ClientIntegrationPlugin-6.5.0.exe
}
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oc:\temp\ B:\VIM_65\VMware-ClientIntegrationPlugin-6.5.0.exe >> C:\ExtractLog.txt
Start-Process C:\temp\VMware-ClientIntegrationPlugin.win32.exe -ArgumentList '/s /v /qn ' -Wait -Verb RunAs
Start-Process C:\temp\VMware-ClientIntegrationService.win32.exe -ArgumentList '/s /v /qn ' -Wait -Verb RunAs
}
60 { 60 {
Write-BuildLog "Starting vCenter 6.0 automation." Write-BuildLog "Starting vCenter 6.0 automation."
if (Test-Path "b:\VIM_60\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") { if (Test-Path "b:\VIM_60\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") {
@ -204,7 +244,9 @@ switch ($vcinstall) {
Write-BuildLog "Installing SQL native client." Write-BuildLog "Installing SQL native client."
Start-Process msiexec -ArgumentList '/i C:\temp\sqlncli.msi ADDLOCAL=ALL IACCEPTSQLNCLILICENSETERMS=YES /qb' -Wait -Verb RunAs Start-Process msiexec -ArgumentList '/i C:\temp\sqlncli.msi ADDLOCAL=ALL IACCEPTSQLNCLILICENSETERMS=YES /qb' -Wait -Verb RunAs
Start-Process regedit -ArgumentList "-s B:\Automate\vc\vCenter6DB.reg" -Wait -Verb RunAs Start-Process regedit -ArgumentList "-s B:\Automate\vc\vCenter6DB.reg" -Wait -Verb RunAs
start-sleep -s 10 do {
start-sleep 10
} until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null)
} }
} else { } else {
Write-BuildLog "SQL Server 2012 Express SP1 for vCenter 6.0 not found. Exiting." Write-BuildLog "SQL Server 2012 Express SP1 for vCenter 6.0 not found. Exiting."
@ -213,6 +255,9 @@ switch ($vcinstall) {
} }
Write-BuildLog "Installing vCentre server 6.0. with embedded PSC" Write-BuildLog "Installing vCentre server 6.0. with embedded PSC"
Start-Process B:\VIM_60\vCenter-Server\VMware-vCenter-Server.exe -ArgumentList " /qr CUSTOM_SETTINGS=B:\Automate\VC\vCentre60.json" -Wait -Verb RunAs Start-Process B:\VIM_60\vCenter-Server\VMware-vCenter-Server.exe -ArgumentList " /qr CUSTOM_SETTINGS=B:\Automate\VC\vCentre60.json" -Wait -Verb RunAs
do {
start-sleep 10
} until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null)
Write-BuildLog "Installing vCentre Client Integration Plugin" Write-BuildLog "Installing vCentre Client Integration Plugin"
If (!(Test-Path("c:\temp\VMware-ClientIntegrationPlugin-6.0.0.exe"))) { If (!(Test-Path("c:\temp\VMware-ClientIntegrationPlugin-6.0.0.exe"))) {
B: B:
@ -226,28 +271,19 @@ switch ($vcinstall) {
$null = copy B:\Automate\vc\SSHAutoConnect\*.* "C:\Program Files (x86)\VMware\Infrastructure\Virtual Infrastructure Client\Plugins\SSHAutoConnect" $null = copy B:\Automate\vc\SSHAutoConnect\*.* "C:\Program Files (x86)\VMware\Infrastructure\Virtual Infrastructure Client\Plugins\SSHAutoConnect"
Write-BuildLog "Installing vSphere Client 6.0 VUM Plugin." Write-BuildLog "Installing vSphere Client 6.0 VUM Plugin."
Start-Process B:\VIM_60\updateManager\VMware-UMClient.exe -ArgumentList '/qb /s /w /L1033 /v" /qr"' -Wait -Verb RunAs Start-Process B:\VIM_60\updateManager\VMware-UMClient.exe -ArgumentList '/qb /s /w /L1033 /v" /qr"' -Wait -Verb RunAs
Write-BuildLog "Installing vSphere Web Client Integration plugin." If (($DeployVUM) -and ($vcinstall -eq "60")) {
if ((Test-Path "b:\VMware-PowerCLI-6.0.*.exe") -and ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)) { do {
Write-BuildLog "VMware PowerCLI 6.0 installer found; installing." start-sleep 10
Start-Process (Get-ChildItem b:\VMware-PowerCLI-6.0.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs } until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null)
} elseif (Test-Path "b:\VMware-PowerCLI-5.8.*.exe") { Write-BuildLog "Installing vCenter Update Manager 6.0."
Write-BuildLog "VMware PowerCLI 5.8 installer found; installing." if ((([System.Environment]::OSVersion.Version.Major *10) + [System.Environment]::OSVersion.Version.Minor) -ge 62) {
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.8.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs Start-Process B:\VIM_60\redist\dotnet\dotnetfx35.exe -ArgumentList " /qb /norestart" -Wait -Verb RunAs
} elseif (Test-Path "b:\VMware-PowerCLI-5.5.*.exe") {
Write-BuildLog "VMware PowerCLI 5.5 installer found; installing."
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.5.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} elseif (Test-Path "b:\VMware-PowerCLI-5.0.*.exe"){
Write-BuildLog "PowerCLI installer is out of date, installing anyway."
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.0.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} else {
If ((Read-Host "Would you like to go to the PowerCLI download site (y/n)?") -like "y") {
$IE=new-object -com internetexplorer.application
if ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62) {$IE.navigate2("https://my.vmware.com/group/vmware/get-download?downloadGroup=PCLI600R1")}
if ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -le 62) {$IE.navigate2("https://my.vmware.com/group/vmware/get-download?downloadGroup=PCLI58R1")}
$IE.visible=$true
} Else { } Else {
Write-Host "OK, but the build will not work correctly without PowerCLI" import-module ServerManager
$null = Add-WindowsFeature AS-NET-Framework
} }
$Arguments = '""/L1033 /v" /qr VMUM_SERVER_SELECT=vc.lab.local VC_SERVER_IP=vc.lab.local VC_SERVER_ADMIN_USER=\"administrator@vsphere.local\" VC_SERVER_ADMIN_PASSWORD=\"VMware1!\" VCI_DB_SERVER_TYPE=Custom VCI_FORMAT_DB=1 DB_DSN=VUM DB_USERNAME=vpx DB_PASSWORD=VMware1!"'
Start-Process B:\VIM_60\updateManager\VMware-UpdateManager.exe -ArgumentList $Arguments -Wait -Verb RunAs
} }
} }
55 { 55 {
@ -295,23 +331,6 @@ switch ($vcinstall) {
Write-BuildLog "Installing vSphere Web Client Integration plugin." Write-BuildLog "Installing vSphere Web Client Integration plugin."
copy "C:\Program Files\VMware\Infrastructure\vSphereWebClient\server\work\deployer\s\global\72\0\container-app-war-5.5.0.war\vmrc\VMware-ClientIntegrationPlugin-5.5.0.exe" c:\ copy "C:\Program Files\VMware\Infrastructure\vSphereWebClient\server\work\deployer\s\global\72\0\container-app-war-5.5.0.war\vmrc\VMware-ClientIntegrationPlugin-5.5.0.exe" c:\
Start-Process C:\VMware-ClientIntegrationPlugin-5.5.0.exe -ArgumentList '/v/qn' -Wait -Verb RunAs Start-Process C:\VMware-ClientIntegrationPlugin-5.5.0.exe -ArgumentList '/v/qn' -Wait -Verb RunAs
if (Test-Path "b:\VMware-PowerCLI-5.8.*.exe") {
Write-BuildLog "VMware PowerCLI installer found; installing."
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.8.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} elseif (Test-Path "b:\VMware-PowerCLI-5.5.*.exe") {
Write-BuildLog "VMware PowerCLI installer found; installing."
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.5.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} elseif (Test-Path "b:\VMware-PowerCLI-5.0.*.exe"){
Write-BuildLog "PowerCLI installer is out of date, installing anyway."
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.0.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} else { If ((Read-Host "Would you like to go to the PowerCLI download site (y/n)?") -like "y") {
$IE=new-object -com internetexplorer.application
$IE.navigate2("https://my.vmware.com/group/vmware/get-download?downloadGroup=PCLI58R1")
$IE.visible=$true
} Else {
Write-Host "OK, but the build will not work correctly without PowerCLI"
}
}
} }
51 { 51 {
Write-BuildLog "Starting vCenter 5.1 automation." Write-BuildLog "Starting vCenter 5.1 automation."
@ -358,13 +377,6 @@ switch ($vcinstall) {
Write-BuildLog "Installing vSphere Web Client Integration plugin." Write-BuildLog "Installing vSphere Web Client Integration plugin."
copy "C:\Program Files\VMware\Infrastructure\vSphereWebClient\server\work\org.eclipse.virgo.kernel.deployer_3.0.3.RELEASE\staging\global\bundle\com.vmware.vsphere.client.containerapp\5.1.0\container-app-war-5.1.0.war\vmrc\VMware-ClientIntegrationPlugin-5.1.0.exe" c:\ copy "C:\Program Files\VMware\Infrastructure\vSphereWebClient\server\work\org.eclipse.virgo.kernel.deployer_3.0.3.RELEASE\staging\global\bundle\com.vmware.vsphere.client.containerapp\5.1.0\container-app-war-5.1.0.war\vmrc\VMware-ClientIntegrationPlugin-5.1.0.exe" c:\
Start-Process C:\VMware-ClientIntegrationPlugin-5.1.0.exe -ArgumentList '/v/qn' -Wait -Verb RunAs Start-Process C:\VMware-ClientIntegrationPlugin-5.1.0.exe -ArgumentList '/v/qn' -Wait -Verb RunAs
if (Test-Path "b:\VMware-PowerCLI-5.1.*.exe") {
Write-BuildLog "VMware PowerCLI installer found; installing."
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.1.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} elseif (Test-Path "b:\VMware-PowerCLI-5.0.*.exe"){
Write-BuildLog "PowerCLI installer is out of date, installing anyway."
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.0.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} else {Write-BuildLog "PowerCLI installer not found."}
} }
5 { 5 {
Write-BuildLog "Starting vCenter 5 automation." Write-BuildLog "Starting vCenter 5 automation."
@ -388,11 +400,7 @@ switch ($vcinstall) {
Write-BuildLog "Installing vCenter and vSphere client." Write-BuildLog "Installing vCenter and vSphere client."
copy b:\automate\vc\vc50.cmd c:\ copy b:\automate\vc\vc50.cmd c:\
start-process c:\vc50.cmd -Wait -verb RunAs start-process c:\vc50.cmd -Wait -verb RunAs
if (Test-Path "b:\VMware-PowerCLI-5.0.*.exe"){ }
Write-BuildLog "VMware PowerCLI installer found; installing."
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.0.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} else {Write-BuildLog "PowerCLI installer not found."}
}
4 { 4 {
Write-BuildLog "Starting vCenter 4.1 automation." Write-BuildLog "Starting vCenter 4.1 automation."
if (Test-Path "b:\VIM_41\redist\SQLEXPR\x64\SQLEXPR.EXE") { if (Test-Path "b:\VIM_41\redist\SQLEXPR\x64\SQLEXPR.EXE") {
@ -408,11 +416,7 @@ switch ($vcinstall) {
} }
copy b:\automate\vc\vc41.cmd c:\ copy b:\automate\vc\vc41.cmd c:\
start-process c:\vc41.cmd -Wait -verb RunAs start-process c:\vc41.cmd -Wait -verb RunAs
if (Test-Path "b:\VMware-PowerCLI-5.0.*.exe"){ }
Write-BuildLog "VMware PowerCLI installer found; installing."
Start-Process (Get-ChildItem b:\VMware-PowerCLI-5.0.*.exe).FullName -ArgumentList '/q /s /w /L1033 /V" /qb"' -Wait -Verb RunAs
} else {Write-BuildLog "PowerCLI installer not found."}
}
Base { Base {
if (Test-Path "b:\VIM_55\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") { if (Test-Path "b:\VIM_55\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") {
Write-BuildLog "SQL Server 2008 R2 Express SP1 for vCenter 5.5 found; installing." Write-BuildLog "SQL Server 2008 R2 Express SP1 for vCenter 5.5 found; installing."
@ -460,6 +464,7 @@ switch ($vcinstall) {
} }
None {} None {}
} }
If ($viewinstall -ne "None") { If ($viewinstall -ne "None") {
$Files = get-childitem "b:\view$viewinstall" $Files = get-childitem "b:\view$viewinstall"
for ($i=0; $i -lt $files.Count; $i++) { for ($i=0; $i -lt $files.Count; $i++) {
@ -467,33 +472,30 @@ If ($viewinstall -ne "None") {
} }
} }
switch ($viewinstall) { switch ($viewinstall) {
70 { 75 {
if (Test-Path "B:\View75\VMware-viewcomposer-*.exe") {
Write-BuildLog "Setup install VMware View 7.5 Composer, reboot required before install"
copy-item $Installer C:\
}
} 70 {
if (Test-Path "B:\View70\VMware-viewcomposer-*.exe") { if (Test-Path "B:\View70\VMware-viewcomposer-*.exe") {
Write-BuildLog "Setup install VMware View 7.0 Composer, reboot required before install" Write-BuildLog "Setup install VMware View 7.0 Composer, reboot required before install"
copy-item $Installer C:\ copy-item $Installer C:\
Write-BuildLog "Setup script recall for Phase 2 completion"
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f >> c:\buildlog.txt
} }
} 60 { } 60 {
if (Test-Path "B:\View60\VMware-viewcomposer-*.exe") { if (Test-Path "B:\View60\VMware-viewcomposer-*.exe") {
Write-BuildLog "Setup install VMware View 6.0 Composer, reboot required before install" Write-BuildLog "Setup install VMware View 6.0 Composer, reboot required before install"
copy-item $Installer C:\ copy-item $Installer C:\
Write-BuildLog "Setup script recall for Phase 2 completion"
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f >> c:\buildlog.txt
} }
} 53 { } 53 {
if (Test-Path "B:\View53\VMware-viewcomposer-5.3*.exe") { if (Test-Path "B:\View53\VMware-viewcomposer-5.3*.exe") {
Write-BuildLog "Setup install VMware View 5.3 Composer, reboot required before install" Write-BuildLog "Setup install VMware View 5.3 Composer, reboot required before install"
copy-item $Installer C:\ copy-item $Installer C:\
Write-BuildLog "Setup script recall for Phase 2 completion"
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f >> c:\buildlog.txt
} }
} 52 { } 52 {
if (Test-Path "B:\View52\VMware-viewcomposer-5.2*.exe") { if (Test-Path "B:\View52\VMware-viewcomposer-5.2*.exe") {
Write-BuildLog "Setup install VMware View 5.2 Composer, reboot required before install" Write-BuildLog "Setup install VMware View 5.2 Composer, reboot required before install"
copy-item $Installer C:\ copy-item $Installer C:\
Write-BuildLog "Setup script recall for Phase 2 completion"
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Runonce /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f >> c:\buildlog.txt
} }
} }
51 { 51 {
@ -518,54 +520,16 @@ if (Test-Path "b:\VMware-vSphere-CLI.exe") {
Write-BuildLog "VMware vSphere CLI installer not found." Write-BuildLog "VMware vSphere CLI installer not found."
} }
Write-BuildLog "Adding Domain Admins to vCenter administrators role and setting PowerCLI certificate warning."
if (!(($vcinstall -eq "None") -or ($vcinstall -eq "Base"))) {
Add-PSSnapin VMware.VimAutomation.Core
$PCLIVer = Get-PowerCLIVersion
if ((($PCLIVer.Major * 10 ) + $PCLIVer.Minor) -ge 51) {
$null = Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -confirm:$false -Scope "AllUsers"
}
If ($vcinstall -eq "60") {
$null = connect-viserver vc.lab.local -user administrator@vsphere.local -password VMware1!
$null = New-VIPermission -Role Admin -Principal 'Administrator' -Entity Datacenters
$null = Disconnect-VIServer -Server * -confirm:$false
If ($DeployVUM) {
Write-BuildLog "Installing vCenter Update Manager 6.0."
if ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62) {
Start-Process B:\VIM_60\redist\dotnet\dotnetfx35.exe -ArgumentList " /qb /norestart" -Wait -Verb RunAs
} Else {
import-module ServerManager
Add-WindowsFeature AS-NET-Framework
}
$Arguments = '""/L1033 /v" /qr VMUM_SERVER_SELECT=vc.lab.local VC_SERVER_IP=vc.lab.local VC_SERVER_ADMIN_USER=\"VC\administrator\" VC_SERVER_ADMIN_PASSWORD=' + $AdminPWD +' VCI_DB_SERVER_TYPE=Custom VCI_FORMAT_DB=1 DB_DSN=VUM DB_USERNAME=vpx DB_PASSWORD=VMware1!"'
Start-Process B:\VIM_60\updateManager\VMware-UpdateManager.exe -ArgumentList $Arguments -Wait -Verb RunAs
}
} ElseIf ($vcinstall -eq "55") {
$null = connect-viserver vc.lab.local -user vc\administrator -password $AdminPWD
$null = New-VIPermission -Role Admin -Principal 'lab\Domain Admins' -Entity Datacenters
$null = Disconnect-VIServer -Server * -confirm:$false
} ElseIf ($vcinstall -eq "51") {
$null = connect-viserver vc.lab.local -user vc\administrator -password $AdminPWD
$null = New-VIPermission -Role Admin -Principal 'Administrators' -Entity Datacenters
$null = Disconnect-VIServer -Server * -confirm:$false
} Else {
$null = connect-viserver vc.lab.local -user vc\administrator -password $AdminPWD
$null = New-VIPermission -Role Admin -Principal 'lab\Domain Admins' -Entity Datacenters
$null = New-VIPermission -Role Admin -Principal 'Administrator' -Entity Datacenters
$null = Disconnect-VIServer -Server * -confirm:$false
}
}
if ($buildvm -and (Test-Path B:\Win2k3.iso)) { if ($buildvm -and (Test-Path B:\Win2k3.iso)) {
Write-BuildLog "Creating fully automated Windows 2003 install ISO." Write-BuildLog "Creating fully automated Windows 2003 install ISO."
$null = New-Item -Path c:\temp\Win2K3 -ItemType Directory -Force $null = New-Item -Path c:\temp\Win2K3 -ItemType Directory -Force
cd c:\temp\Win2K3 cd c:\temp\Win2K3
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa b:\win2k3.iso >> c:\temp\Extractlog.txt . "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa b:\win2k3.iso >> c:\temp\Extractlog.txt
cmd /c copy c:\temp\Win2K3\[BOOT]\Bootable_NoEmulation.img c:\temp\Win2K3\win2k3.img cmd /c copy C:\temp\Win2K3\[BOOT]\Boot-NoEmul.img C:\temp\Win2K3\Win2K3.img
if (!(Test-Path b:\Auto2K3.iso)) { if (!(Test-Path b:\Auto2K3.iso)) {
Copy-Item -Path C:\temp\Auto2K3.sif -Destination c:\temp\Win2K3\i386\winnt.sif -Force Copy-Item -Path C:\temp\Auto2K3.sif -Destination c:\temp\Win2K3\i386\winnt.sif -Force
Copy-Item B:\Automate\_Common\Auto2K3.cmd c:\temp\Win2k3 Copy-Item B:\Automate\_Common\Auto2K3.cmd c:\temp\Win2k3
b:\automate\vc\mkisofs -b win2k3.img -c boot.catalog -hide boot.catalog -no-emul-boot -boot-load-seg 1984 -boot-load-size 4 -iso-level 2 -J -l -D -N -joliet-long -quiet -relaxed-filenames -V "WIN2K3" -o b:\Auto2K3.iso . b:\automate\vc\mkisofs -b Win2K3.img -c boot.catalog -hide boot.catalog -no-emul-boot -boot-load-seg 1984 -boot-load-size 4 -iso-level 2 -J -l -D -N -joliet-long -quiet -relaxed-filenames -V "WIN2K3" -o b:\Auto2K3.iso .
} }
if (!(Test-Path b:\Windows2K3.iso)) { if (!(Test-Path b:\Windows2K3.iso)) {
Write-BuildLog "Creating Lab Windows 2003 install ISO" Write-BuildLog "Creating Lab Windows 2003 install ISO"
@ -599,7 +563,7 @@ if ($buildviewvm -and (Test-Path B:\WinXP.iso)) {
} }
if (!(Test-Path b:\AutoXP.iso)){ if (!(Test-Path b:\AutoXP.iso)){
Write-BuildLog "Creating fully automated Windows XP install ISO for VMware View" Write-BuildLog "Creating fully automated Windows XP install ISO for VMware View"
cmd /c copy c:\temp\WinXP\[BOOT]\Bootable_NoEmulation.img c:\temp\WinXP\winXP.img cmd /c copy c:\temp\WinXP\[BOOT]\Boot-NoEmul.img c:\temp\WinXP\winXP.img
rd c:\temp\WinXP\[BOOT] rd c:\temp\WinXP\[BOOT]
Move-Item -Path C:\temp\AutoXP.sif -Destination c:\temp\WinXP\i386\winnt.sif Move-Item -Path C:\temp\AutoXP.sif -Destination c:\temp\WinXP\i386\winnt.sif
$null = New-Item -Path C:\temp\WinXP\$OEM$ -ItemType Directory -Force $null = New-Item -Path C:\temp\WinXP\$OEM$ -ItemType Directory -Force
@ -612,6 +576,11 @@ if ($buildviewvm -and (Test-Path B:\WinXP.iso)) {
cd c:\ cd c:\
} }
if (!(($vcinstall -eq "None") -or ($vcinstall -eq "Base"))) {
$PCLIVernum = deployPowerCLI
Copy-Item -Path "b:\automate\vc\Phase2.ps1" "c:\Phase2.ps1" -force
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v Build /t REG_SZ /d "c:\windows\syswow64\WindowsPowerShell\v1.0\powershell.exe c:\Phase2.ps1" /f
}
Write-BuildLog "Cleanup and creating Desktop shortcuts." Write-BuildLog "Cleanup and creating Desktop shortcuts."
regedit -s b:\Automate\vc\vSphereClient.reg regedit -s b:\Automate\vc\vSphereClient.reg
Remove-Item "C:\Users\Public\Desktop\*.lnk" Remove-Item "C:\Users\Public\Desktop\*.lnk"
@ -623,23 +592,17 @@ Remove-Item c:\temp\* -Force -Recurse
copy b:\Automate\vc\Shortcuts.vbs c:\Shortcuts.vbs copy b:\Automate\vc\Shortcuts.vbs c:\Shortcuts.vbs
wscript c:\Shortcuts.vbs wscript c:\Shortcuts.vbs
copy b:\Automate\*.ps1 c:\ copy b:\Automate\*.ps1 c:\
If ((([System.Environment]::OSVersion.Version.Major *10) + [System.Environment]::OSVersion.Version.Minor) -ge 62) {
Write-BuildLog "Disable Internet Explorer Enhanced Security to allow access to Web Client" Write-BuildLog "Disable Internet Explorer Enhanced Security to allow access to Web Client"
$AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}" $AdminKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A7-37EF-4b3f-8CFC-4F3A74704073}"
$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" $UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}"
Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0
Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0
If (($AutoAddHosts -eq "True") -and (Test-Path "c:\Addhosts.ps1")){
Write-BuildLog " "
Write-BuildLog "Automatically running AddHosts script."
Write-BuildLog " "
Start-Process c:\windows\syswow64\WindowsPowerShell\v1.0\powershell.exe -ArgumentList " C:\AddHosts.ps1" -wait
} }
Write-BuildLog "Installing VMware tools, build complete after reboot." Write-BuildLog "Installing VMware tools, build complete after reboot."
if (Test-Path B:\VMTools\setup64.exe) { if (Test-Path B:\VMTools\setup64.exe) {
#Read-Host "End of install checkpoint, before VMTools" #Read-Host "End of install checkpoint, before VMTools"
if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none")){ if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none") -and (($vcinstall -eq "None") -or ($vcinstall -eq "Base"))){
$mailmessage = New-Object system.net.mail.mailmessage $mailmessage = New-Object system.net.mail.mailmessage
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25) $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$mailmessage.from = "AutoLab<autolab@labguides.com>" $mailmessage.from = "AutoLab<autolab@labguides.com>"
@ -652,6 +615,8 @@ if (Test-Path B:\VMTools\setup64.exe) {
$attach = new-object Net.Mail.Attachment("C:\buildlog.txt") $attach = new-object Net.Mail.Attachment("C:\buildlog.txt")
$mailmessage.Attachments.Add($attach) $mailmessage.Attachments.Add($attach)
$SMTPClient.Send($mailmessage) $SMTPClient.Send($mailmessage)
$mailmessage.dispose()
$SMTPClient.dispose()
} }
Start-Process B:\VMTools\setup64.exe -ArgumentList '/s /v "/qn"' -verb RunAs -Wait Start-Process B:\VMTools\setup64.exe -ArgumentList '/s /v "/qn"' -verb RunAs -Wait
} }

View File

@ -0,0 +1,95 @@
. "C:\PSFunctions.ps1"
Write-BuildLog "Phase2.ps1 waiting ten more minutes for vCentre services to finish starting"
start-sleep 600
Write-BuildLog "Determining automate.ini settings."
$viewinstall = ((Select-String -SimpleMatch "ViewInstall=" -Path "B:\Automate\automate.ini").line).substring(12)
Write-BuildLog " VMware View install set to $viewinstall."
$vcinstall = "55"
$vcinstall = ((Select-String -SimpleMatch "VCInstall=" -Path "B:\Automate\automate.ini").line).substring(10)
If ($vcinstall -eq "50") {$vcinstall = "5"}
$AutoAddHosts = ((Select-String -SimpleMatch "AutoAddHosts=" -Path "B:\Automate\automate.ini").line).substring(13)
if ($AutoAddHosts -like "true") {
$AutoAddHosts = $true
Write-BuildLog " Hosts will be automatically added to vCenter after build completes."
} else {
$AutoAddHosts = $false
}
$DeployVUM = $false
if ((((Select-String -SimpleMatch "DeployVUM=" -Path "B:\Automate\automate.ini").line).substring(10)) -like "true") {
$DeployVUM = $true
Write-BuildLog " VUM will be installed."
} else {
$DeployVUM = $false
Write-BuildLog " No VUM."
}
$AdminPWD = "VMware1!"
$AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9)
$emailto = ((Select-String -SimpleMatch "emailto=" -Path "B:\Automate\automate.ini").line).substring(8)
$SmtpServer = ((Select-String -SimpleMatch "SmtpServer=" -Path "B:\Automate\automate.ini").line).substring(11)
$PCLIVernum = "Now PowerCLI"
$PCLIVernum = Get-PowerCLIVersion
Write-BuildLog "Adding Domain Admins to vCenter administrators role and setting PowerCLI $PCLIVernum certificate warning."
If (($vcinstall -eq "67") -or ($vcinstall -eq "65")) {
$null = connect-viserver vc.lab.local -user administrator@vsphere.local -password VMware1!
$null = New-VIPermission -Role Admin -Principal 'Administrator' -Entity Datacenters
$null = Disconnect-VIServer -Server * -confirm:$false
} elseif ($vcinstall -eq "60") {
$null = connect-viserver vc.lab.local -user administrator@vsphere.local -password VMware1!
$null = New-VIPermission -Role Admin -Principal 'Administrator' -Entity Datacenters
$null = Disconnect-VIServer -Server * -confirm:$false
} ElseIf (($vcinstall -eq "55") -or ($vcinstall -eq "51")) {
$null = connect-viserver vc.lab.local -user vc\administrator -password $AdminPWD
$null = New-VIPermission -Role Admin -Principal 'Administrators' -Entity Datacenters
$null = Disconnect-VIServer -Server * -confirm:$false
} Else {
$null = connect-viserver vc.lab.local -user vc\administrator -password $AdminPWD
$null = New-VIPermission -Role Admin -Principal 'lab\Domain Admins' -Entity Datacenters
$null = New-VIPermission -Role Admin -Principal 'Administrator' -Entity Datacenters
$null = Disconnect-VIServer -Server * -confirm:$false
}
If (($AutoAddHosts -eq "True") -and (Test-Path "c:\Addhosts.ps1")){
Write-BuildLog "Automatically running AddHosts script."
Start-Process c:\windows\syswow64\WindowsPowerShell\v1.0\powershell.exe -ArgumentList " C:\AddHosts.ps1" -wait
}
if (Test-Path "C:\VMware-viewcomposer*") {
$Files = get-childitem "C:\"
for ($i=0; $i -lt $files.Count; $i++) {
If ($Files[$i].Name -like "VMware-viewcomposer*") {$Installer = $Files[$i].FullName}
}
switch ($viewinstall) {
75 {
Write-BuildLog "Installing VMware View 7.5 Composer"
Start-Process $Installer -ArgumentList '/s /v" /qn AgreeToLicense="Yes" DB_USERNAME="VMview" DB_PASSWORD="VMware1!" DB_DSN="ViewComposer" REBOOT="ReallySuppress" "' -Wait -Verb RunAs
} 70 {
Write-BuildLog "Installing VMware View 7.0 Composer"
Start-Process $Installer -ArgumentList '/s /v" /qn AgreeToLicense="Yes" DB_USERNAME="VMview" DB_PASSWORD="VMware1!" DB_DSN="ViewComposer" REBOOT="ReallySuppress" "' -Wait -Verb RunAs
} 60 {
Write-BuildLog "Installing VMware View 6.0 Composer"
Start-Process $Installer -ArgumentList '/s /v" /qn AgreeToLicense="Yes" DB_USERNAME="VMview" DB_PASSWORD="VMware1!" DB_DSN="ViewComposer" REBOOT="ReallySuppress" "' -Wait -Verb RunAs
} 53 {
Write-BuildLog "Installing VMware View 5.3 Composer"
Start-Process $Installer -ArgumentList '/s /v" /qn AgreeToLicense="Yes" DB_USERNAME="VMview" DB_PASSWORD="VMware1!" DB_DSN="ViewComposer" REBOOT="ReallySuppress" "' -Wait -Verb RunAs
} 52 {
Write-BuildLog "Installing VMware View 5.2 Composer"
Start-Process $Installer -ArgumentList '/s /v" /qn AgreeToLicense="Yes" DB_USERNAME="VMview" DB_PASSWORD="VMware1!" DB_DSN="ViewComposer" REBOOT="ReallySuppress" "' -Wait -Verb RunAs
}
}
}
if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none")){
Write-BuildLog "Emailing log"
$mailmessage = New-Object system.net.mail.mailmessage
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$mailmessage.from = "AutoLab<autolab@labguides.com>"
$mailmessage.To.add($emailto)
$Summary = "Completed AutoLab VM build.`r`n"
$Summary += "The build of $env:computername has finished, installing VMware Tools and rebooting`r`n"
$Summary += "The build log is attached`r`n"
$mailmessage.Subject = "$env:computername VM build finished"
$mailmessage.Body = $Summary
$attach = new-object Net.Mail.Attachment("C:\buildlog.txt")
$mailmessage.Attachments.Add($attach)
$SMTPClient.Send($mailmessage)
$mailmessage.dispose()
$SMTPClient.dispose()
}

View File

@ -1,14 +1,4 @@
set WshShell = WScript.CreateObject("WScript.Shell") set WshShell = WScript.CreateObject("WScript.Shell")
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\vSphere.lnk")
oShortCutLink.TargetPath = "C:\Program Files (x86)\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\VpxClient.exe"
oShortCutLink.Arguments = "-s vc.lab.local -PassthroughAuth"
oShortCutLink.Save
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\VMware vSphere Client.lnk")
oShortCutLink.TargetPath = "C:\Program Files (x86)\VMware\Infrastructure\Virtual Infrastructure Client\Launcher\VpxClient.exe"
oShortCutLink.Save
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\AutoLab Script Menu.lnk") set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\AutoLab Script Menu.lnk")
oShortCutLink.TargetPath = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" oShortCutLink.TargetPath = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"
oShortCutLink.Arguments = " c:\ScriptMenu.ps1" oShortCutLink.Arguments = " c:\ScriptMenu.ps1"

View File

@ -70,5 +70,32 @@
"vmdir.password" : "VMware1!", "vmdir.password" : "VMware1!",
"vmdir.replication-partner-hostname" : null, "vmdir.replication-partner-hostname" : null,
"vmdir.site-name" : "Default-First-Site", "vmdir.site-name" : "Default-First-Site",
"vmware.data.directory" : "C:\\ProgramData\\VMware\\" "vmware.data.directory" : "C:\\ProgramData\\VMware\\",
"ceip": {
"__comments": [
"++++VMware Customer Experience Improvement Program (CEIP)++++",
"VMware's Customer Experience Improvement Program (CEIP) ",
"provides VMware with information that enables VMware to ",
"improve its products and services, to fix problems, ",
"and to advise you on how best to deploy and use our ",
"products. As part of the CEIP, VMware collects technical ",
"information about your organization's use of VMware products ",
"and services on a regular basis in association with your ",
"organization's VMware license key(s). This information does ",
"not personally identify any individual. ",
"For more details about the Program and how VMware uses ",
"the information it collects through CEIP, please see the ",
"[http://www.vmware.com/info?id=1399 product documentation]. ",
"By default we have 'ceip.enabled': true, which indicates ",
"that you are joining CEIP. If you prefer not to ",
"participate in VMware's CEIP for this product, you should ",
"disable CEIP by setting 'ceip.enable': false. You may join ",
"or leave VMware's CEIP for this product at any time. Please ",
"confirm your acknowledgement by setting ",
"'ceip.acknowledged': true. ",
"++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++"
],
"ceip.enabled": true,
"ceip.acknowledged": true
}
} }

View File

@ -1,14 +1,18 @@
# Build Validation script for vSphere 6.0 AutoLab # Build Validation script for vSphere AutoLab
# #
# Version 2.6 # Version 3.0
# #
# #
# Include the functions script, this is used to keep this script clean # Include the functions script, this is used to keep this script clean
$Auto = $False
foreach ($arg in $args) {
If ($arg -like "auto") { $Auto = $True}
}
if (Test-Path C:\PSFunctions.ps1) { if (Test-Path C:\PSFunctions.ps1) {
. "C:\PSFunctions.ps1" . "C:\PSFunctions.ps1"
} else { } else {
Write-Host "PSFunctions.ps1 not found. Please copy all PowerShell files from B:\Automate to C:\ and rerun AddHosts.ps1" Write-Host "PSFunctions.ps1 not found. Please copy all PowerShell files from B:\Automate to C:\ and rerun AddHosts.ps1"
Read-Host "Press <Enter> to exit" If (!($Auto)) {Read-Host "Press <Enter> to exit" }
exit exit
} }
@ -23,13 +27,19 @@ if (Test-Administrator) {
# make script window as tall as possible # make script window as tall as possible
$a = (Get-Host).UI.RawUI $a = (Get-Host).UI.RawUI
$a.WindowTitle = "AutoLab Validation"
$b = $a.WindowSize $b = $a.WindowSize
$b.Height = $a.MaxWindowSize.Height - 1 $b.Height = $a.MaxWindowSize.Height - 1
$a.WindowSize = $b $a.WindowSize = $b
Import-Module C:\windows\system32\WASP.dll Import-Module C:\windows\system32\WASP.dll
Select-Window -Title "Administrator:" | set-windowposition -left 3 -top 3 Select-Window -Title "AutoLab Validation" | set-windowposition -left 75 -top 3
If (!(Test-Path "B:\*")) { If (!(Test-Path "B:\Automate\automate.ini" -ErrorAction SilentlyContinue)) {
net use B: \\192.168.199.7\Build net use b: \\192.168.199.7\Build
}
$BDrive = $true
If (!(Test-Path "B:\Automate\automate.ini" -ErrorAction SilentlyContinue)) {
$BDrive = $false
Write-Host "B: Drive not mapped, less tests"
} }
$CompName = gc env:computername $CompName = gc env:computername
Write-Host "Validating" $CompName -foregroundcolor "cyan" Write-Host "Validating" $CompName -foregroundcolor "cyan"
@ -37,52 +47,54 @@ Write-Host "Error events from system eventlog on " $CompName -foregroundcolor "c
get-eventlog -LogName System -entrytype Error -ErrorAction SilentlyContinue | Format-table -property TimeGenerated, Message -autosize get-eventlog -LogName System -entrytype Error -ErrorAction SilentlyContinue | Format-table -property TimeGenerated, Message -autosize
if ($CompName -eq "DC") { if ($CompName -eq "DC") {
Write-Host "Validating required Build share components." -foregroundcolor "cyan" Write-Host "Validating required Build share components." -foregroundcolor "cyan"
$AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9) if ($BDrive) {
If ($AdminPWD -eq "VMware1!") { $AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9)
Write-Host "Default admin password set, this isn't safe." -foregroundcolor "Red" If (($AdminPWD -eq "VMware1!") -and (!($Auto))) {
$NewPWD = Read-Host "Enter a new admin password" Write-Host "Default admin password set, this isn't safe." -foregroundcolor "Red"
If ($NewPWD -ne "") { $NewPWD = Read-Host "Enter a new admin password"
Write-Host "Setting new password" -foregroundcolor "Green" If ($NewPWD -ne "") {
$OldAdminPWD = $AdminPWD Write-Host "Setting new password" -foregroundcolor "Green"
$AdminPWD = $NewPWD $OldAdminPWD = $AdminPWD
$FileContent = get-content B:\Automate\automate.ini $AdminPWD = $NewPWD
Set-Content B:\Automate\automate.ini "" $FileContent = get-content B:\Automate\automate.ini
Foreach ($Line in $FileContent){ Set-Content B:\Automate\automate.ini ""
If ($Line.StartsWith("Adminpwd")) { $Line = "Adminpwd=$NewPWD"} Foreach ($Line in $FileContent){
Add-Content B:\Automate\automate.ini $Line If ($Line.StartsWith("Adminpwd")) { $Line = "Adminpwd=$NewPWD"}
Add-Content B:\Automate\automate.ini $Line
}
net user SVC_Veeam $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user SVC_SRM $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user DomUser $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user vi-admin $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user administrator $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user ada $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user alan $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user grace $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user charles $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
B:\automate\_Common\Autologon administrator lab $AdminPWD
$TempContent = Get-Content B:\Automate\Hosts\esx1-4.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx1-4.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx1-5.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx1-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx2-4.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx2-4.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx2-4c.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx2-4c.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx2-5.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx2-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx3-5.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx3-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx4-5.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx4-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx11-5.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx11-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx12-5.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx12-5.cfg
$service = gwmi win32_service -filter "name='MSSQL`$SQLEXPRESS'"
$null = $service.change($null,$null,$null,$null,$null,$null,$null,$AdminPWD)
Write-Host "Restarting SQL Express with new password" -foregroundcolor "Green"
$null = Restart-Service "MSSQL`$SQLEXPRESS" -force
} }
net user SVC_Veeam $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user SVC_SRM $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user DomUser $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user vi-admin $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user administrator $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user ada $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user alan $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user grace $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user charles $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
B:\automate\_Common\Autologon administrator lab $AdminPWD
$TempContent = Get-Content B:\Automate\Hosts\esx1-4.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx1-4.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx1-5.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx1-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx2-4.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx2-4.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx2-4c.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx2-4c.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx2-5.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx2-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx3-5.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx3-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx4-5.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx4-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx11-5.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx11-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx12-5.cfg |%{$_ -replace $OldAdminPWD,$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx12-5.cfg
$service = gwmi win32_service -filter "name='MSSQL`$SQLEXPRESS'"
$null = $service.change($null,$null,$null,$null,$null,$null,$null,$AdminPWD)
Write-Host "Restarting SQL Express with new password" -foregroundcolor "Green"
$null = Restart-Service "MSSQL`$SQLEXPRESS" -force
} }
} }
If ((Get-WmiObject Win32_BIOS).Manufacturer.Tolower() -like "bochs*") { If ((Get-WmiObject Win32_BIOS).Manufacturer.Tolower() -like "bochs*") {
@ -98,82 +110,104 @@ if ($CompName -eq "DC") {
Write-Host "Make sure the ESXi hosts are properly built & restart cleanly" -foregroundcolor "cyan" Write-Host "Make sure the ESXi hosts are properly built & restart cleanly" -foregroundcolor "cyan"
} }
} }
$vSpherePaths = @{"ESX41"="\\192.168.199.7\Build\ESX41\*";"ESXi41"="\\192.168.199.7\Build\ESXi41\*";"vCenter41"="\\192.168.199.7\Build\VIM_41\*";"ESXi50"="\\192.168.199.7\Build\ESXi50\*";"vCenter50"="\\192.168.199.7\Build\VIM_50\*";"ESXi51"="\\192.168.199.7\Build\ESXi51\*";"vCenter51"="\\192.168.199.7\Build\VIM_51\*";"ESXi55"="\\192.168.199.7\Build\ESXi55\*";"vCenter55"="\\192.168.199.7\Build\VIM_55\*";"ESXi60"="\\192.168.199.7\Build\ESXi60\*";"vCenter60"="\\192.168.199.7\Build\VIM_60\*"} if ($BDrive) {
$vSpherePaths.GetEnumerator() | % {if (!(Test-Path $_.Value)) {New-Variable -Name $_.Name -Value $false -force} else {New-Variable -Name $_.Name -Value $true -force}} $vSpherePaths = @{"ESX41"="\\192.168.199.7\Build\ESX41\*";"ESXi41"="\\192.168.199.7\Build\ESXi41\*";"vCenter41"="\\192.168.199.7\Build\VIM_41\*";"ESXi50"="\\192.168.199.7\Build\ESXi50\*";"vCenter50"="\\192.168.199.7\Build\VIM_50\*";"ESXi51"="\\192.168.199.7\Build\ESXi51\*";"vCenter51"="\\192.168.199.7\Build\VIM_51\*";"ESXi55"="\\192.168.199.7\Build\ESXi55\*";"vCenter55"="\\192.168.199.7\Build\VIM_55\*";"ESXi60"="\\192.168.199.7\Build\ESXi60\*";"vCenter60"="\\192.168.199.7\Build\VIM_60\*";"ESXi65"="\\192.168.199.7\Build\ESXi65\*";"vCenter65"="\\192.168.199.7\Build\VIM_65\*";"ESXi67"="\\192.168.199.7\Build\ESXi67\*";"vCenter67"="\\192.168.199.7\Build\VIM_67\*"}
if ($vCenter41 -and ($ESXi41 -or $ESX41)) { $vSpherePaths.GetEnumerator() | % {if (!(Test-Path $_.Value)) {New-Variable -Name $_.Name -Value $false -force} else {New-Variable -Name $_.Name -Value $true -force}}
Write-Host "vCenter 4.1 & ESXi 4.1 found." -foregroundcolor "green" if ($vCenter41 -and ($ESXi41 -or $ESX41)) {
$vSphere41 = $true Write-Host "vCenter 4.1 & ESXi 4.1 found." -foregroundcolor "green"
} elseif ($vCenter41 -or ($ESXi41 -or $ESX41)) { $vSphere41 = $true
Write-Host "vSphere 4.1 installation requirements not met. Please verify that both vCenter 4.1 & ESXi 4.1 exist on Build share." -foregroundcolor "red" } elseif ($vCenter41 -or ($ESXi41 -or $ESX41)) {
$vSphere41 = $false Write-Host "vSphere 4.1 installation requirements not met. Please verify that both vCenter 4.1 & ESXi 4.1 exist on Build share." -foregroundcolor "red"
} else { $vSphere41 = $false
Write-Host "vCenter 4.1 & ESXi 4.1 not found." -foregroundcolor "cyan" } else {
$vSphere41 = $false Write-Host "vCenter 4.1 & ESXi 4.1 not found." -foregroundcolor "cyan"
} $vSphere41 = $false
if ($vCenter50 -and $ESXi50) {
Write-Host "vCenter 5.0 & ESXi 5.0 found." -foregroundcolor "green"
$vSphere50 = $true
} elseif ($vCenter50 -or $ESXi50) {
Write-Host "vSphere 5.0 installation requirements not met. Please verify that both vCenter 5.0 & ESXi 5.0 exist on Build share." -foregroundcolor "red"
$vSphere50 = $false
} else {
Write-Host "vCenter 5.0 & ESXi 5.0 not found." -foregroundcolor "cyan"
$vSphere50 = $false
}
if ($vCenter51 -and $ESXi51) {
Write-Host "vCenter 5.1 & ESXi 5.1 found." -foregroundcolor "green"
$vSphere51 = $true
} elseif ($vCenter51 -or $ESXi51) {
Write-Host "vSphere 5.1 installation requirements not met. Please verify that both vCenter 5.1 & ESXi 5.1 exist on Build share." -foregroundcolor "red"
$vSphere51 = $false
} else {
Write-Host "vCenter 5.1 & ESXi 5.1 not found." -foregroundcolor "cyan"
$vSphere51 = $false
}
if ($vCenter55 -and $ESXi55) {
Write-Host "vCenter 5.5 & ESXi 5.5 found." -foregroundcolor "green"
$vSphere55 = $true
} elseif ($vCenter55 -or $ESXi55) {
Write-Host "vSphere 5.5 installation requirements not met. Please verify that both vCenter 5.5 & ESXi 5.5 exist on Build share." -foregroundcolor "red"
$vSphere55 = $false
} else {
Write-Host "vCenter 5.5 & ESXi 5.5 not found." -foregroundcolor "cyan"
$vSphere55 = $false
}
if ($vCenter60 -and $ESXi60) {
Write-Host "vCenter 6.0 & ESXi 6.0 found." -foregroundcolor "green"
$vSphere60 = $true
} elseif ($vCenter60 -or $ESXi60) {
Write-Host "vSphere 6.0 installation requirements not met. Please verify that both vCenter 6.0 & ESXi 6.0 exist on Build share." -foregroundcolor "red"
$vSphere60 = $false
} else {
Write-Host "vCenter 6.0 & ESXi 6.0 not found." -foregroundcolor "cyan"
$vSphere60 = $false
}
if (!($vSphere41 -or $vSphere50 -or $vSphere51 -or $vSphere55 -or $vSphere60)) {
Write-Host "Matching vCenter & ESXi distributions not found. Please check the Build share." -foregroundcolor "red"
$Global:Pass = $false
}
Check-File "\\192.168.199.7\Build\VMware-PowerCLI*.exe" "PowerCLI installer"
If (!(Test-Path "\\192.168.199.7\Build\VMware-PowerCLI*.exe")) {
If ((Read-Host "Would you like to go to the PowerCLI download site (y/n)?") -like "y") {
$IE=new-object -com internetexplorer.application
if ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62) {$IE.navigate2("https://my.vmware.com/group/vmware/get-download?downloadGroup=PCLI600R1")}
if ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -le 62) {$IE.navigate2("https://my.vmware.com/group/vmware/get-download?downloadGroup=PCLI58R1")}
$IE.visible=$true
} Else {
Write-Host "OK, but the VC build will not work correctly without PowerCLI"
} }
if ($vCenter50 -and $ESXi50) {
Write-Host "vCenter 5.0 & ESXi 5.0 found." -foregroundcolor "green"
$vSphere50 = $true
} elseif ($vCenter50 -or $ESXi50) {
Write-Host "vSphere 5.0 installation requirements not met. Please verify that both vCenter 5.0 & ESXi 5.0 exist on Build share." -foregroundcolor "red"
$vSphere50 = $false
} else {
Write-Host "vCenter 5.0 & ESXi 5.0 not found." -foregroundcolor "cyan"
$vSphere50 = $false
}
if ($vCenter51 -and $ESXi51) {
Write-Host "vCenter 5.1 & ESXi 5.1 found." -foregroundcolor "green"
$vSphere51 = $true
} elseif ($vCenter51 -or $ESXi51) {
Write-Host "vSphere 5.1 installation requirements not met. Please verify that both vCenter 5.1 & ESXi 5.1 exist on Build share." -foregroundcolor "red"
$vSphere51 = $false
} else {
Write-Host "vCenter 5.1 & ESXi 5.1 not found." -foregroundcolor "cyan"
$vSphere51 = $false
}
if ($vCenter55 -and $ESXi55) {
Write-Host "vCenter 5.5 & ESXi 5.5 found." -foregroundcolor "green"
$vSphere55 = $true
} elseif ($vCenter55 -or $ESXi55) {
Write-Host "vSphere 5.5 installation requirements not met. Please verify that both vCenter 5.5 & ESXi 5.5 exist on Build share." -foregroundcolor "red"
$vSphere55 = $false
} else {
Write-Host "vCenter 5.5 & ESXi 5.5 not found." -foregroundcolor "cyan"
$vSphere55 = $false
}
if ($vCenter60 -and $ESXi60) {
Write-Host "vCenter 6.0 & ESXi 6.0 found." -foregroundcolor "green"
$vSphere60 = $true
} elseif ($vCenter60 -or $ESXi60) {
Write-Host "vSphere 6.0 installation requirements not met. Please verify that both vCenter 6.0 & ESXi 6.0 exist on Build share." -foregroundcolor "red"
$vSphere60 = $false
} else {
Write-Host "vCenter 6.0 & ESXi 6.0 not found." -foregroundcolor "cyan"
$vSphere60 = $false
}
if ($vCenter65 -and $ESXi65) {
Write-Host "vCenter 6.5 & ESXi 6.5 found." -foregroundcolor "green"
$vSphere65 = $true
} elseif ($vCenter65 -or $ESXi65) {
Write-Host "vSphere 6.5 installation requirements not met. Please verify that both vCenter 6.5 & ESXi 6.5 exist on Build share." -foregroundcolor "red"
$vSphere65 = $false
} else {
Write-Host "vCenter 6.5 & ESXi 6.5 not found." -foregroundcolor "cyan"
$vSphere65 = $false
}
if ($vCenter67 -and $ESXi67) {
Write-Host "vCenter 6.7 & ESXi 6.7 found." -foregroundcolor "green"
$vSphere67 = $true
} elseif ($vCenter67 -or $ESXi67) {
Write-Host "vSphere 6.7 installation requirements not met. Please verify that both vCenter 6.7 & ESXi 6.7 exist on Build share." -foregroundcolor "red"
$vSphere67 = $false
} else {
Write-Host "vCenter 6.7 & ESXi 6.7 not found." -foregroundcolor "cyan"
$vSphere67 = $false
}
if (!($vSphere41 -or $vSphere50 -or $vSphere51 -or $vSphere55 -or $vSphere60 -or $vSphere65 -or $vSphere67)) {
Write-Host "Matching vCenter & ESXi distributions not found. Please check the Build share." -foregroundcolor "red"
$Global:Pass = $false
}
Check-File "\\192.168.199.7\Build\VMware-PowerCLI*.exe" "PowerCLI installer"
If ((!(Test-Path "\\192.168.199.7\Build\VMware-PowerCLI*.exe")) -and (!($Auto))) {
If ((Read-Host "Would you like to go to the PowerCLI download site (y/n)?") -like "y") {
$IE=new-object -com internetexplorer.application
if ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62) {$IE.navigate2("https://my.vmware.com/group/vmware/get-download?downloadGroup=PCLI600R1")}
if ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -le 62) {$IE.navigate2("https://my.vmware.com/group/vmware/get-download?downloadGroup=PCLI58R1")}
$IE.visible=$true
} Else {
Write-Host "OK, but the VC build will not work correctly without PowerCLI"
}
}
if (Test-Path "b:\VMware-PowerCLI-5*.exe") {
If (($vSphere50 -and ((Get-ChildItem B:\VMware-PowerCLI-*.exe | where {$_.VersionInfo.ProductVersion -like "5.0*"}) -eq $Null))) {Write-Host "vSphere 5.0 found, matching PowerCLI version missing. Please check the Build share." -foregroundcolor "Yellow"}
If (($vSphere51 -and ((Get-ChildItem B:\VMware-PowerCLI-*.exe | where {$_.VersionInfo.ProductVersion -like "5.1*"}) -eq $Null))) {Write-Host "vSphere 5.1 found, matching PowerCLI version missing. Please check the Build share." -foregroundcolor "Yellow"}
If (($vSphere55 -and (((Get-ChildItem B:\VMware-PowerCLI-*.exe | where {$_.VersionInfo.ProductVersion -like "5.5*"}) -eq $Null) -and ((Get-ChildItem B:\VMware-PowerCLI-*.exe | where {$_.VersionInfo.ProductVersion -like "5.8*"}) -eq $Null)))) {Write-Host "vSphere 5.5 found, matching PowerCLI version missing. Please check the Build share." -foregroundcolor "Yellow"}
If (($vSphere60 -and (((Get-ChildItem B:\VMware-PowerCLI-*.exe | where {$_.VersionInfo.ProductVersion -like "5.8*"}) -eq $Null) -and ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -le 62)))) {Write-Host "vSphere 6.0 on Windows 2008 found, matching PowerCLI version 5.8 missing. Please check the Build share." -foregroundcolor "Yellow"}
If (($vSphere60 -and (((Get-ChildItem B:\VMware-PowerCLI-*.exe | where {$_.VersionInfo.ProductVersion -like "6*"}) -eq $Null) -and ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)))) {Write-Host "vSphere 6.0 on Windows 2012 found, matching PowerCLI version 6 missing. Please check the Build share." -foregroundcolor "Yellow"}
}
Check-OptionalFile "\\192.168.199.7\Build\Win2K3.iso" "Windows Server 2003 ISO"
Check-OptionalFile "\\192.168.199.7\Build\WinXP.iso" "Windows XP ISO"
} }
if (Test-Path "b:\VMware-PowerCLI-5*.exe") {
If (($vSphere50 -and ((Get-ChildItem B:\VMware-PowerCLI-*.exe | where {$_.VersionInfo.ProductVersion -like "5.0*"}) -eq $Null))) {Write-Host "vSphere 5.0 found, matching PowerCLI version missing. Please check the Build share." -foregroundcolor "Yellow"}
If (($vSphere51 -and ((Get-ChildItem B:\VMware-PowerCLI-*.exe | where {$_.VersionInfo.ProductVersion -like "5.1*"}) -eq $Null))) {Write-Host "vSphere 5.1 found, matching PowerCLI version missing. Please check the Build share." -foregroundcolor "Yellow"}
If (($vSphere55 -and (((Get-ChildItem B:\VMware-PowerCLI-*.exe | where {$_.VersionInfo.ProductVersion -like "5.5*"}) -eq $Null) -and ((Get-ChildItem B:\VMware-PowerCLI-*.exe | where {$_.VersionInfo.ProductVersion -like "5.8*"}) -eq $Null)))) {Write-Host "vSphere 5.5 found, matching PowerCLI version missing. Please check the Build share." -foregroundcolor "Yellow"}
If (($vSphere60 -and (((Get-ChildItem B:\VMware-PowerCLI-*.exe | where {$_.VersionInfo.ProductVersion -like "5.8*"}) -eq $Null) -and ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -le 62)))) {Write-Host "vSphere 6.0 on Windows 2008 found, matching PowerCLI version 5.8 missing. Please check the Build share." -foregroundcolor "Yellow"}
If (($vSphere60 -and (((Get-ChildItem B:\VMware-PowerCLI-*.exe | where {$_.VersionInfo.ProductVersion -like "6*"}) -eq $Null) -and ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62)))) {Write-Host "vSphere 6.0 on Windows 2012 found, matching PowerCLI version 6 missing. Please check the Build share." -foregroundcolor "Yellow"}
}
Check-OptionalFile "\\192.168.199.7\Build\Win2K3.iso" "Windows Server 2003 ISO"
Check-OptionalFile "\\192.168.199.7\Build\WinXP.iso" "Windows XP ISO"
Write-Host "Validate SQL & TFTP Install" -foregroundcolor "cyan" Write-Host "Validate SQL & TFTP Install" -foregroundcolor "cyan"
if (Test-Path -LiteralPath "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\") { if (Test-Path -LiteralPath "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\") {
Check-File "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\vCenter.mdf" "vCenter Database" Check-File "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\vCenter.mdf" "vCenter Database"
@ -185,60 +219,70 @@ if ($CompName -eq "DC") {
Check-File "C:\Program Files\Tftpd64_SE\Tftpd64_SVC.exe" "TFTP Server" Check-File "C:\Program Files\Tftpd64_SE\Tftpd64_SVC.exe" "TFTP Server"
Check-File "C:\TFTP-Root\pxelinux.0" "PXE boot file" Check-File "C:\TFTP-Root\pxelinux.0" "PXE boot file"
Check-File "C:\TFTP-Root\pxelinux.cfg" "PXE boot configuration file" Check-File "C:\TFTP-Root\pxelinux.cfg" "PXE boot configuration file"
if ($ESX41 -and (Test-Path "C:\TFTP-Root\ESX41\*")) { if ($BDrive) {
Write-Host "ESX 4.1 TFTP files found." -foregroundcolor "green" if ($ESX41 -and (Test-Path "C:\TFTP-Root\ESX41\*")) {
} elseif ($ESX41 -and !(Test-Path "C:\TFTP-Root\ESX41\*")) { Write-Host "ESX 4.1 TFTP files found." -foregroundcolor "green"
Write-Host "ESX 4.1 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red" } elseif ($ESX41 -and !(Test-Path "C:\TFTP-Root\ESX41\*")) {
$Global:Pass = $false Write-Host "ESX 4.1 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red"
} $Global:Pass = $false
if ($ESXi41 -and (Test-Path "C:\TFTP-Root\ESXi41\*")) { }
Write-Host "ESXi 4.1 TFTP files found." -foregroundcolor "green" if ($ESXi41 -and (Test-Path "C:\TFTP-Root\ESXi41\*")) {
} elseif ($ESXi41 -and !(Test-Path "C:\TFTP-Root\ESXi41\*")) { Write-Host "ESXi 4.1 TFTP files found." -foregroundcolor "green"
Write-Host "ESXi 4.1 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red" } elseif ($ESXi41 -and !(Test-Path "C:\TFTP-Root\ESXi41\*")) {
$Global:Pass = $false Write-Host "ESXi 4.1 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red"
} $Global:Pass = $false
if ($ESXi50 -and (Test-Path "C:\TFTP-Root\ESXi50\*")) { }
Write-Host "ESXi 5.0 TFTP files found." -foregroundcolor "green" if ($ESXi50 -and (Test-Path "C:\TFTP-Root\ESXi50\*")) {
} elseif ($ESXi50 -and !(Test-Path "C:\TFTP-Root\ESXi50\*")) { Write-Host "ESXi 5.0 TFTP files found." -foregroundcolor "green"
Write-Host "ESXi 5.0 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red" } elseif ($ESXi50 -and !(Test-Path "C:\TFTP-Root\ESXi50\*")) {
$Global:Pass = $false Write-Host "ESXi 5.0 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red"
} $Global:Pass = $false
if ($ESXi51 -and (Test-Path "C:\TFTP-Root\ESXi51\*")) { }
Write-Host "ESXi 5.1 TFTP files found." -foregroundcolor "green" if ($ESXi51 -and (Test-Path "C:\TFTP-Root\ESXi51\*")) {
} elseif ($ESXi51 -and !(Test-Path "C:\TFTP-Root\ESXi51\*")) { Write-Host "ESXi 5.1 TFTP files found." -foregroundcolor "green"
Write-Host "ESXi 5.1 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red" } elseif ($ESXi51 -and !(Test-Path "C:\TFTP-Root\ESXi51\*")) {
$Global:Pass = $false Write-Host "ESXi 5.1 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red"
} $Global:Pass = $false
if ($ESXi55 -and (Test-Path "C:\TFTP-Root\ESXi515\*")) { }
Write-Host "ESXi 5.5 TFTP files found." -foregroundcolor "green" if ($ESXi55 -and (Test-Path "C:\TFTP-Root\ESXi515\*")) {
} elseif ($ESXi55 -and !(Test-Path "C:\TFTP-Root\ESXi55\*")) { Write-Host "ESXi 5.5 TFTP files found." -foregroundcolor "green"
Write-Host "ESXi 5.5 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red" } elseif ($ESXi55 -and !(Test-Path "C:\TFTP-Root\ESXi55\*")) {
$Global:Pass = $false Write-Host "ESXi 5.5 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red"
} $Global:Pass = $false
if ($ESXi60 -and (Test-Path "C:\TFTP-Root\ESXi60\*")) { }
Write-Host "ESXi 6.0 TFTP files found." -foregroundcolor "green" if ($ESXi60 -and (Test-Path "C:\TFTP-Root\ESXi60\*")) {
} elseif ($ESXi60 -and !(Test-Path "C:\TFTP-Root\ESXi60\*")) { Write-Host "ESXi 6.0 TFTP files found." -foregroundcolor "green"
Write-Host "ESXi 6.0 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red" } elseif ($ESXi60 -and !(Test-Path "C:\TFTP-Root\ESXi60\*")) {
$Global:Pass = $false Write-Host "ESXi 6.0 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red"
} $Global:Pass = $false
}
$vcinstall = ((Select-String -SimpleMatch "VCInstall=" -Path "B:\Automate\automate.ini").line).substring(10) $vcinstall = ((Select-String -SimpleMatch "VCInstall=" -Path "B:\Automate\automate.ini").line).substring(10)
If ($vcinstall -eq "50") {$vcinstall = "5"} If ($vcinstall -eq "50") {$vcinstall = "5"}
If (!($vSphere50) -and ($vcinstall -eq "5")) { If (!($vSphere50) -and ($vcinstall -eq "5")) {
Write-Host "You wish to install vSphere 5.0 but the installers aren't on the build share" -foregroundcolor "red" Write-Host "You wish to install vSphere 5.0 but the installers aren't on the build share" -foregroundcolor "red"
$Global:Pass = $false $Global:Pass = $false
} }
If (!($vSphere51) -and ($vcinstall -eq "51")) { If (!($vSphere51) -and ($vcinstall -eq "51")) {
Write-Host "You wish to install vSphere 5.1 but the installers aren't on the build share" -foregroundcolor "red" Write-Host "You wish to install vSphere 5.1 but the installers aren't on the build share" -foregroundcolor "red"
$Global:Pass = $false $Global:Pass = $false
} }
If (!($vSphere55) -and ($vcinstall -eq "55")) { If (!($vSphere55) -and ($vcinstall -eq "55")) {
Write-Host "You wish to install vSphere 5.5 but the installers aren't on the build share" -foregroundcolor "red" Write-Host "You wish to install vSphere 5.5 but the installers aren't on the build share" -foregroundcolor "red"
$Global:Pass = $false $Global:Pass = $false
} }
If (!($vSphere60) -and ($vcinstall -eq "60")) { If (!($vSphere60) -and ($vcinstall -eq "60")) {
Write-Host "You wish to install vSphere 6.0 but the installers aren't on the build share" -foregroundcolor "red" Write-Host "You wish to install vSphere 6.0 but the installers aren't on the build share" -foregroundcolor "red"
$Global:Pass = $false $Global:Pass = $false
}
If (!($vSphere65) -and ($vcinstall -eq "65")) {
Write-Host "You wish to install vSphere 6.5 but the installers aren't on the build share" -foregroundcolor "red"
$Global:Pass = $false
}
If (!($vSphere67) -and ($vcinstall -eq "67")) {
Write-Host "You wish to install vSphere 6.7 but the installers aren't on the build share" -foregroundcolor "red"
$Global:Pass = $false
}
} }
Write-Host "Check Domain" -foregroundcolor "cyan" Write-Host "Check Domain" -foregroundcolor "cyan"
$domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain()
@ -256,7 +300,7 @@ if ($CompName -eq "DC") {
Check-ServiceRunning "Tftpd32_svc" Check-ServiceRunning "Tftpd32_svc"
Check-ServiceRunning "SQL Server (SQLEXPRESS)" Check-ServiceRunning "SQL Server (SQLEXPRESS)"
Check-ServiceRunning "SQLBrowser" Check-ServiceRunning "SQLBrowser"
If ((Get-VMPlatform) -eq "VMware") {Check-ServiceRunning "VMTools"} If (((Get-VMPlatform) -eq "VMware") -and (!($Auto))) {Check-ServiceRunning "VMTools"}
Write-Host "Check DNS" -foregroundcolor "cyan" Write-Host "Check DNS" -foregroundcolor "cyan"
Check-DNSRecord ("dc.lab.local") Check-DNSRecord ("dc.lab.local")
Check-DNSRecord ("vc.lab.local") Check-DNSRecord ("vc.lab.local")
@ -277,13 +321,13 @@ if ($CompName -eq "DC") {
if ($CompName -eq "VC") { if ($CompName -eq "VC") {
$HaveXP = test-Path("\\192.168.199.7\Build\WinXP.iso") $HaveXP = test-Path("\\192.168.199.7\Build\WinXP.iso")
$Have2K3 = test-Path("\\192.168.199.7\Build\Win2K3.iso") $Have2K3 = test-Path("\\192.168.199.7\Build\Win2K3.iso")
If ((Get-VMPlatform) -eq "VMware") {Check-ServiceRunning "VMTools"} If (((Get-VMPlatform) -eq "VMware") -and (!($Auto))) {Check-ServiceRunning "VMTools"}
$VCPath = "None" $VCPath = "None"
If (Test-path "C:\ProgramData\VMware\VMware VirtualCenter") { If (Test-path "C:\ProgramData\VMware\VMware VirtualCenter") {
$VCPath = "C:\ProgramData\VMware\VMware VirtualCenter" $VCPath = "C:\ProgramData\VMware\VMware VirtualCenter"
$VCVer = (Get-ItemProperty -Path "HKLM:\SOFTWARE\VMware, Inc.\VMware VirtualCenter").InstalledVersion $VCVer = (Get-ItemProperty -Path "HKLM:\SOFTWARE\VMware, Inc.\VMware VirtualCenter" -ErrorAction SilentlyContinue).InstalledVersion
} }
If (Test-path "C:\ProgramData\VMware\vCenterServer") { If (Test-path "C:\ProgramData\VMware\vCenterServer") {
$VCPath = "C:\ProgramData\VMware\vCenterServer\cfg\vmware-vpx" $VCPath = "C:\ProgramData\VMware\vCenterServer\cfg\vmware-vpx"
$VCVer = (Get-ItemProperty -Path "HKLM:\SOFTWARE\VMware, Inc.\vCenter Server").ProductVersion $VCVer = (Get-ItemProperty -Path "HKLM:\SOFTWARE\VMware, Inc.\vCenter Server").ProductVersion
} }
@ -305,15 +349,27 @@ if ($CompName -eq "VC") {
Check-ServiceRunning "VMware VirtualCenter Management Webservices" Check-ServiceRunning "VMware VirtualCenter Management Webservices"
Check-ServiceRunning "VMware VirtualCenter Server" Check-ServiceRunning "VMware VirtualCenter Server"
} }
if ($VCVer.StartsWith("6")) { if ($VCVer.StartsWith("6.0")) {
if ((((Select-String -SimpleMatch "DeployVUM=" -Path "B:\Automate\automate.ini").line).substring(10)) -like "true") {Check-ServiceRunning "VMware vSphere Update Manager Service"} if ((((Select-String -SimpleMatch "DeployVUM=" -Path "B:\Automate\automate.ini").line).substring(10)) -like "true") {Check-ServiceRunning "VMware vSphere Update Manager Service"}
Check-ServiceRunning "VMware VirtualCenter Server" Check-ServiceRunning "VMware VirtualCenter Server"
Check-ServiceRunning "VMware vSphere Web Client" Check-ServiceRunning "VMware vSphere Web Client"
Check-ServiceRunning "VMware Directory Service" Check-ServiceRunning "VMware Directory Service"
Check-ServiceRunning "VMware vSphere Profile-Driven Storage Service" Check-ServiceRunning "VMware vSphere Profile-Driven Storage Service"
} }
if ($VCVer.StartsWith("6.5")) {
Check-ServiceRunning "VMWareDirectoryService"
Check-ServiceRunning "VMwareDNSService"
Check-ServiceRunning "VMwareIdentityMgmtService"
Check-ServiceRunning "VMwareSTS"
Check-ServiceRunning "vmware-psc-client"
}
if ($VCVer.StartsWith("6.7")) {
Check-ServiceRunning "VMWareDirectoryService"
Check-ServiceRunning "VMwareDNSService"
Check-ServiceRunning "VMwareIdentityMgmtService"
Check-ServiceRunning "VMwareSTS"
}
} }
} Else { } Else {
Write-Host "vCenter is not installed" -foregroundcolor "Yellow" Write-Host "vCenter is not installed" -foregroundcolor "Yellow"
} }
@ -338,7 +394,7 @@ if ($CompName -eq "DC2") {
Check-ServiceRunning "Netlogon" Check-ServiceRunning "Netlogon"
Check-ServiceRunning "SQL Server (SQLEXPRESS)" Check-ServiceRunning "SQL Server (SQLEXPRESS)"
Check-ServiceRunning "SQLBrowser" Check-ServiceRunning "SQLBrowser"
If ((Get-VMPlatform) -eq "VMware") {Check-ServiceRunning "VMTools"} If (((Get-VMPlatform) -eq "VMware") -and (!($Auto))) {Check-ServiceRunning "VMTools"}
Write-Host "Check DNS" -foregroundcolor "cyan" Write-Host "Check DNS" -foregroundcolor "cyan"
Check-DNSRecord ("dc.lab.local") Check-DNSRecord ("dc.lab.local")
Check-DNSRecord ("vc.lab.local") Check-DNSRecord ("vc.lab.local")
@ -358,7 +414,7 @@ if ($CompName -eq "DC2") {
} }
if ($CompName -eq "VC2") { if ($CompName -eq "VC2") {
If ((Get-VMPlatform) -eq "VMware") {Check-ServiceRunning "VMTools"} If (((Get-VMPlatform) -eq "VMware") -and (!($Auto))) {Check-ServiceRunning "VMTools"}
If (Test-path "C:\ProgramData\VMware\VMware VirtualCenter") { If (Test-path "C:\ProgramData\VMware\VMware VirtualCenter") {
Write-Host "Check Services" -foregroundcolor "cyan" Write-Host "Check Services" -foregroundcolor "cyan"
Check-ServiceRunning "VMware VirtualCenter Management Webservices" Check-ServiceRunning "VMware VirtualCenter Management Webservices"
@ -368,7 +424,10 @@ if ($CompName -eq "VC2") {
Write-Host "vCenter is not installed" -foregroundcolor "Yellow" Write-Host "vCenter is not installed" -foregroundcolor "Yellow"
} }
} }
if (($CompName -eq "CS1") -or ($CompName -eq "CS2") -or ($CompName -eq "SS")) {
Check-ServiceRunning "wsbroker"
Check-ServiceRunning "PCOIPSG"
}
Write-Host "The final result" -foregroundcolor "cyan" Write-Host "The final result" -foregroundcolor "cyan"
if ($Global:Pass -eq $false ) { if ($Global:Pass -eq $false ) {
Write-Host ("*****************************************") -foregroundcolor "red" Write-Host ("*****************************************") -foregroundcolor "red"
@ -387,4 +446,4 @@ if ($Global:Pass -eq $false ) {
Write-Host ("*") -foregroundcolor "green" Write-Host ("*") -foregroundcolor "green"
Write-Host ("**************************************") -foregroundcolor "green" Write-Host ("**************************************") -foregroundcolor "green"
} }
Read-host " Press <Enter> to exit" If (!($Auto)) {Read-host " Press <Enter> to exit"}

View File

@ -1,7 +1,7 @@
** **
* Autolab V2.6 * Autolab V3.0
** **
* Released April 2015 * Released June 2018
** **
* New versions and updates at www.labguides.com * New versions and updates at www.labguides.com
** **

Binary file not shown.

View File

@ -0,0 +1,19 @@
Write-Host "Loading PowerCLI, this may take a little while." -foregroundcolor "cyan"
if (((Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) -eq $null) -and ((Get-PSSnapin -Registered).name -contains "ware")) {
Add-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue
} else {
$moduleList = @( "VMware.VimAutomation.Core", "VMware.VimAutomation.Vds", "VMware.VimAutomation.Cis.Core", "VMware.VimAutomation.Storage", "VMware.VimAutomation.HorizonView","VMware.VimAutomation.HA", "VMware.VimAutomation.vROps", "VMware.VumAutomation", "VMware.DeployAutomation", "VMware.ImageBuilder", "VMware.VimAutomation.License")
$loaded = Get-Module -Name $moduleList -ErrorAction Ignore | % {$_.Name}
$registered = Get-Module -Name $moduleList -ListAvailable -ErrorAction Ignore | % {$_.Name}
$notLoaded = $registered | ? {$loaded -notcontains $_}
foreach ($module in $registered) {
if ($loaded -notcontains $module) {
Import-Module $module
}
}
}
$PCLIVer = Get-PowerCLIVersion
if ((($PCLIVer.Major * 10 ) + $PCLIVer.Minor) -ge 51) {
$null = Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -confirm:$false -Scope "Session"
}

View File

@ -2,7 +2,7 @@
TZ=New Zealand Standard Time TZ=New Zealand Standard Time
VCInstall=60 VCInstall=60
VCInstallOptions=4,5,51,55,60,None,Base VCInstallOptions=4,5,51,55,60,65,67,None,Base
AutoAddHosts=false AutoAddHosts=false
DeployVUM=true DeployVUM=true
Adminpwd=VMware1! Adminpwd=VMware1!
@ -12,7 +12,7 @@ BuildVM=true
ProductKey=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX ProductKey=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX
ViewInstall=None ViewInstall=None
ViewInstallOptions=50,51,52,53,60,None ViewInstallOptions=50,51,52,53,60,70,None
BuildViewVM=true BuildViewVM=true
ViewVMProductKey=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX ViewVMProductKey=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX

View File

@ -1,5 +1,12 @@
Version xx Version 3.0
- Support for vSphere 6.5 & 6.7
- Support for Windows Server 2016
- Removed support for Windows Server 2008
- Added Email notification for VC & DC build. Specify destination address & SMTP server in autolmate.ini - Added Email notification for VC & DC build. Specify destination address & SMTP server in autolmate.ini
- Changed router to pfSense
- Updated NAS to FreeNAS 11.1
- Support for View 7.5
- Nested 2008, 2016, Windows 7, Windows 8, & Windows 10 VMs
Version 2.6 Version 2.6
- Support for vSphere 6.0 - Support for vSphere 6.0

View File

@ -1,4 +1,4 @@
To have gParted addedto PXE menu place teh following fiels here before the DC build To have gParted addedto PXE menu place the following files here before the DC build
filesystem.squashfs filesystem.squashfs
initrd.img initrd.img

View File

@ -18,7 +18,7 @@
<InstallFrom> <InstallFrom>
<MetaData wcm:action="add"> <MetaData wcm:action="add">
<Key>/IMAGE/INDEX</Key> <Key>/IMAGE/INDEX</Key>
<Value>1</Value> <Value>2</Value>
</MetaData> </MetaData>
</InstallFrom> </InstallFrom>
</OSImage> </OSImage>
@ -134,9 +134,21 @@
<FirstLogonCommands> <FirstLogonCommands>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>a:\Build.cmd</CommandLine> <CommandLine>a:\Build.cmd</CommandLine>
<Description>Build</Description> <Description>Phase One Installer from A Drive</Description>
<Order>1</Order> <Order>1</Order>
<RequiresUserInput>true</RequiresUserInput> <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>D:\Build.cmd</CommandLine>
<Description>Phase One Installer from D Drive</Description>
<Order>2</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>E:\Build.cmd</CommandLine>
<Description>Phase One Installer from E Drive</Description>
<Order>3</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand> </SynchronousCommand>
</FirstLogonCommands> </FirstLogonCommands>
</component> </component>

View File

@ -6,27 +6,22 @@ ver | find "6.2" > nul
if %ERRORLEVEL% == 0 goto ver_2K12 if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "6.3" > nul ver | find "6.3" > nul
if %ERRORLEVEL% == 0 goto ver_2K12 if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "10.0" > nul
if %ERRORLEVEL% == 0 goto ver_2K16
goto RunBuild goto RunBuild
:ver_2K8 :ver_2K8
goto RunBuild goto RunBuild
:ver_2K12 :ver_2K12
:ver_2K16
netsh interface ip set address name="Ethernet" static 192.168.199.33 255.255.255.0 192.168.199.2 1 netsh interface ip set address name="Ethernet" static 192.168.199.33 255.255.255.0 192.168.199.2 1
netsh interface ip set address name="Ethernet0" static 192.168.199.33 255.255.255.0 192.168.199.2 1
ping 192.168.199.2
netsh interface ip set dnsservers name="Ethernet" static address=192.168.199.4 primary netsh interface ip set dnsservers name="Ethernet" static address=192.168.199.4 primary
netsh interface ip set dnsservers name="Ethernet0" static address=192.168.199.4 primary
Dism /online /enable-feature /featurename:NetFx3ServerFeatures Dism /online /enable-feature /featurename:NetFx3ServerFeatures
Dism /online /enable-feature /featurename:NetFx3 /source:D:\Sources\sxs Dism /online /enable-feature /featurename:NetFx3 /source:D:\Sources\sxs
copy \\192.168.199.7\Build\Automate\DC\ocsetup.exe c:\windows\system32\ copy \\192.168.199.7\Build\Automate\DC\ocsetup.exe c:\windows\system32\
echo * Mount Install Image
echo * Mount Install Image >> c:\buildlog.txt
mkdir c:\mountdir
Dism /mount-wim /WimFile:D:\sources\install.wim /Index:2 /MountDir:c:\mountdir /readonly /quiet
echo * Setup recall of build script
copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\
type \\192.168.199.7\Build\Automate\version.txt >> c:\buildlog.txt
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\build.cmd" /f >> c:\buildlog.txt
echo * Install GUI onto Server Core
echo * Install GUI onto Server Core >> c:\buildlog.txt
Dism /online /enable-feature /featurename:server-gui-shell /all /source:c:\mountdir\windows\winsxs /quiet
pause
goto RunBuild goto RunBuild
:RunBuild :RunBuild
copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\ copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\

View File

@ -18,7 +18,7 @@
<InstallFrom> <InstallFrom>
<MetaData wcm:action="add"> <MetaData wcm:action="add">
<Key>/IMAGE/INDEX</Key> <Key>/IMAGE/INDEX</Key>
<Value>1</Value> <Value>2</Value>
</MetaData> </MetaData>
</InstallFrom> </InstallFrom>
</OSImage> </OSImage>
@ -130,10 +130,22 @@
</UserAccounts> </UserAccounts>
<FirstLogonCommands> <FirstLogonCommands>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>a:\Build.cmd</CommandLine> <CommandLine>A:\Build.cmd</CommandLine>
<Description>Build</Description> <Description>Phase One Installer from A Drive</Description>
<Order>1</Order> <Order>1</Order>
<RequiresUserInput>true</RequiresUserInput> <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>D:\Build.cmd</CommandLine>
<Description>Phase One Installer from D Drive</Description>
<Order>2</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>E:\Build.cmd</CommandLine>
<Description>Phase One Installer from E Drive</Description>
<Order>3</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand> </SynchronousCommand>
</FirstLogonCommands> </FirstLogonCommands>
</component> </component>

View File

@ -6,27 +6,21 @@ ver | find "6.2" > nul
if %ERRORLEVEL% == 0 goto ver_2K12 if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "6.3" > nul ver | find "6.3" > nul
if %ERRORLEVEL% == 0 goto ver_2K12 if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "10.0" > nul
if %ERRORLEVEL% == 0 goto ver_2K16
goto RunBuild goto RunBuild
:ver_2K8 :ver_2K8
goto RunBuild goto RunBuild
:ver_2K12 :ver_2K12
:ver_2K16
netsh interface ip set address name="Ethernet" static 192.168.199.34 255.255.255.0 192.168.199.2 1 netsh interface ip set address name="Ethernet" static 192.168.199.34 255.255.255.0 192.168.199.2 1
netsh interface ip set address name="Ethernet0" static 192.168.199.34 255.255.255.0 192.168.199.2 1
ping 192.168.199.2
netsh interface ip set dnsservers name="Ethernet" static address=192.168.199.4 primary netsh interface ip set dnsservers name="Ethernet" static address=192.168.199.4 primary
netsh interface ip set dnsservers name="Ethernet0" static address=192.168.199.4 primary
Dism /online /enable-feature /featurename:NetFx3ServerFeatures Dism /online /enable-feature /featurename:NetFx3ServerFeatures
Dism /online /enable-feature /featurename:NetFx3 /source:D:\Sources\sxs Dism /online /enable-feature /featurename:NetFx3 /source:D:\Sources\sxs
copy \\192.168.199.7\Build\Automate\DC\ocsetup.exe c:\windows\system32\ copy \\192.168.199.7\Build\Automate\DC\ocsetup.exe c:\windows\system32\
echo * Mount Install Image
echo * Mount Install Image >> c:\buildlog.txt
mkdir c:\mountdir
Dism /mount-wim /WimFile:D:\sources\install.wim /Index:2 /MountDir:c:\mountdir /readonly /quiet
echo * Setup recall of build script
copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\
type \\192.168.199.7\Build\Automate\version.txt >> c:\buildlog.txt
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\build.cmd" /f >> c:\buildlog.txt
echo * Install GUI onto Server Core
echo * Install GUI onto Server Core >> c:\buildlog.txt
Dism /online /enable-feature /featurename:server-gui-shell /all /source:c:\mountdir\windows\winsxs /quiet
pause
goto RunBuild goto RunBuild
:RunBuild :RunBuild
copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\ copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\

View File

@ -5,49 +5,65 @@ ver | find "6.2" > nul
if %ERRORLEVEL% == 0 goto ver_2K12 if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "6.3" > nul ver | find "6.3" > nul
if %ERRORLEVEL% == 0 goto ver_2K12 if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "10." > nul
if %ERRORLEVEL% == 0 goto ver_2K16
Exit Exit
:ver_2K8 :ver_2K8
echo ** echo **
echo * Building on Windows 2008 R2 echo * Building on Windows 2008 core
echo * Building on Windows 2008 R2 >> c:\buildlog.txt echo * Building on Windows 2008 core >> c:\buildlog.txt
DISM.exe /online /enable-feature /featurename:NetFx2-ServerCore >> c:\buildlog.txt
DISM.exe /online /enable-feature /featurename:NetFx3-ServerCore >> c:\buildlog.txt
DISM.exe /online /enable-feature /featurename:NetFx2-ServerCore-WOW64 >> c:\buildlog.txt
DISM.exe /online /enable-feature /featurename:NetFx3-ServerCore-WOW64 >> c:\buildlog.txt
DISM.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShell >> c:\buildlog.txt
DISM.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShell-WOW64 >> c:\buildlog.txt
echo * Set IP address
echo * Set IP address >> c:\buildlog.txt
netsh interface ip set address "Ethernet" static 192.168.199.4 255.255.255.0 192.168.199.2 1
netsh interface ip set address "Ethernet0" static 192.168.199.4 255.255.255.0 192.168.199.2 1
ping 192.168.199.2
netsh interface ip set dnsservers "Ethernet" static 192.168.199.4 primary
netsh interface ip set dnsservers "Ethernet0" static 192.168.199.4 primary
ping 192.168.199.7 >> c:\buildlog.txt
echo * Setup recall of build script echo * Setup recall of build script
echo * Setup recall of build script >> c:\buildlog.txt echo * Setup recall of build script >> c:\buildlog.txt
copy \\192.168.199.7\Build\Automate\DC\Phase2.cmd c:\ >> c:\buildlog.txt copy \\192.168.199.7\Build\Automate\DC\Phase2.cmd c:\ >> c:\buildlog.txt
type \\192.168.199.7\Build\Automate\version.txt >> c:\buildlog.txt type \\192.168.199.7\Build\Automate\version.txt >> c:\buildlog.txt
echo **
echo * Install DHCP
echo * Install DHCP >> c:\buildlog.txt
start /w ocsetup DHCPServer
echo * Enable DHCP
echo * Enable DHCP >> c:\buildlog.txt
sc config dhcpserver start= auto
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\Phase2.cmd" /f >> c:\buildlog.txt reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\Phase2.cmd" /f >> c:\buildlog.txt
echo ** echo * Promote to DC
echo * Install Active Directory and reboot echo * Promote to DC >> c:\buildlog.txt
copy \\192.168.199.7\Build\Automate\DC\dcpromo.txt c:\ >> c:\buildlog.txt copy \\192.168.199.7\Build\Automate\DC\dcpromo.txt c:\dcpromo.txt >> c:\buildlog.txt
dcpromo /answer:c:\dcpromo.txt >> c:\buildlog.txt dcpromo /answer:c:\dcpromo.txt >> c:\buildlog.txt
Exit exit
:ver_2K12 :ver_2K12
echo ** echo **
echo * Building on Windows 2012 R2 echo * Building on Windows 2012 R2
echo * Building on Windows 2012 R2 >> c:\buildlog.txt echo * Building on Windows 2012 R2 >> c:\buildlog.txt
goto startBuild
:ver_2K16
echo **
echo * Building on Windows 2016
echo * Building on Windows 2016 >> c:\buildlog.txt
goto startBuild
:startBuild
echo * Set IP address echo * Set IP address
echo * Set IP address >> c:\buildlog.txt echo * Set IP address >> c:\buildlog.txt
netsh interface ip set address "Ethernet" static 192.168.199.4 255.255.255.0 192.168.199.2 1 netsh interface ip set address "Ethernet" static 192.168.199.4 255.255.255.0 192.168.199.2 1
netsh interface ip set address "Ethernet0" static 192.168.199.4 255.255.255.0 192.168.199.2 1
ping 192.168.199.2
netsh interface ip set dnsservers "Ethernet" static 192.168.199.4 primary netsh interface ip set dnsservers "Ethernet" static 192.168.199.4 primary
echo ** netsh interface ip set dnsservers "Ethernet0" static 192.168.199.4 primary
echo * Mount Install Image ping 192.168.199.7 >> c:\buildlog.txt
echo * Mount Install Image >> c:\buildlog.txt
mkdir c:\mountdir
If Exist D:\sources\install.wim Dism /mount-wim /WimFile:D:\sources\install.wim /Index:2 /MountDir:c:\mountdir /readonly /quiet
If Exist E:\sources\install.wim Dism /mount-wim /WimFile:E:\sources\install.wim /Index:2 /MountDir:c:\mountdir /readonly /quiet
echo * Setup recall of build script echo * Setup recall of build script
echo * Setup recall of build script >> c:\buildlog.txt
copy \\192.168.199.7\Build\Automate\DC\Phase2.cmd c:\ >> c:\buildlog.txt copy \\192.168.199.7\Build\Automate\DC\Phase2.cmd c:\ >> c:\buildlog.txt
type \\192.168.199.7\Build\Automate\version.txt >> c:\buildlog.txt type \\192.168.199.7\Build\Automate\version.txt >> c:\buildlog.txt
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\Phase2.cmd" /f >> c:\buildlog.txt reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\Phase2.cmd" /f >> c:\buildlog.txt
echo * Install GUI onto Server Core #echo * Promote to DC
echo * Install GUI onto Server Core >> c:\buildlog.txt #echo * Promote to DC >> c:\buildlog.txt
Dism /online /enable-feature /featurename:server-gui-mgmt /all /source:c:\mountdir\windows\winsxs /quiet /norestart #copy \\192.168.199.7\Build\Automate\DC\dcpromo.ps1 c:\
Dism /online /enable-feature /featurename:server-gui-shell /all /source:c:\mountdir\windows\winsxs /quiet /norestart #pause
Dism /online /enable-feature /featurename:servercore-fullserver /all /source:c:\mountdir\windows\winsxs /quiet #powershell c:\dcpromo.ps1
#pause Installing AD, will reboot after
Exit Exit

View File

@ -1,53 +0,0 @@
@echo off
ver | find "6.1" > nul
if %ERRORLEVEL% == 0 goto ver_2K8
ver | find "6.2" > nul
if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "6.3" > nul
if %ERRORLEVEL% == 0 goto ver_2K12
Exit
:ver_2K8
echo **
echo * Building on Windows 2008 R2
echo * Building on Windows 2008 R2 >> c:\buildlog.txt
echo * Setup recall of build script
echo * Setup recall of build script >> c:\buildlog.txt
copy \\192.168.199.7\Build\Automate\DC\Phase2.cmd c:\ >> c:\buildlog.txt
type \\192.168.199.7\Build\Automate\version.txt >> c:\buildlog.txt
echo **
echo * Install DHCP
echo * Install DHCP >> c:\buildlog.txt
start /w ocsetup DHCPServer
echo * Enable DHCP
echo * Enable DHCP >> c:\buildlog.txt
sc config dhcpserver start= auto
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\Phase2.cmd" /f >> c:\buildlog.txt
echo **
echo * Install Active Directory and reboot
copy \\192.168.199.7\Build\Automate\DC\dcpromo.txt c:\ >> c:\buildlog.txt
dcpromo /answer:c:\dcpromo.txt >> c:\buildlog.txt
Exit
:ver_2K12
echo **
echo * Building on Windows 2012 R2
echo * Building on Windows 2012 R2 >> c:\buildlog.txt
echo * Set IP address
echo * Set IP address >> c:\buildlog.txt
netsh interface ip set address "Ethernet" static 192.168.199.4 255.255.255.0 192.168.199.2 1
netsh interface ip set dnsservers "Ethernet" static 192.168.199.4 primary
echo **
echo * Mount Install Image
echo * Mount Install Image >> c:\buildlog.txt
mkdir c:\mountdir
If Exist D:\sources\install.wim Dism /mount-wim /WimFile:D:\sources\install.wim /Index:2 /MountDir:c:\mountdir /readonly /quiet
If Exist E:\sources\install.wim Dism /mount-wim /WimFile:E:\sources\install.wim /Index:2 /MountDir:c:\mountdir /readonly /quiet
echo * Setup recall of build script
copy \\192.168.199.7\Build\Automate\DC\Phase2.cmd c:\ >> c:\buildlog.txt
type \\192.168.199.7\Build\Automate\version.txt >> c:\buildlog.txt
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\Phase2.cmd" /f >> c:\buildlog.txt
echo * Install GUI onto Server Core
echo * Install GUI onto Server Core >> c:\buildlog.txt
Dism /online /enable-feature /featurename:server-gui-mgmt /all /source:c:\mountdir\windows\winsxs /quiet /norestart
Dism /online /enable-feature /featurename:server-gui-shell /all /source:c:\mountdir\windows\winsxs /quiet /norestart
Dism /online /enable-feature /featurename:servercore-fullserver /all /source:c:\mountdir\windows\winsxs /quiet
Exit

Binary file not shown.

Binary file not shown.

View File

@ -18,7 +18,7 @@
<InstallFrom> <InstallFrom>
<MetaData wcm:action="add"> <MetaData wcm:action="add">
<Key>/IMAGE/INDEX</Key> <Key>/IMAGE/INDEX</Key>
<Value>1</Value> <Value>2</Value>
</MetaData> </MetaData>
</InstallFrom> </InstallFrom>
</OSImage> </OSImage>
@ -107,13 +107,13 @@
<Order>1</Order> <Order>1</Order>
<RequiresUserInput>true</RequiresUserInput> <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand> </SynchronousCommand>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>D:\Build.cmd</CommandLine> <CommandLine>D:\Build.cmd</CommandLine>
<Description>Phase One Installer from D Drive</Description> <Description>Phase One Installer from D Drive</Description>
<Order>2</Order> <Order>2</Order>
<RequiresUserInput>true</RequiresUserInput> <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand> </SynchronousCommand>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>E:\Build.cmd</CommandLine> <CommandLine>E:\Build.cmd</CommandLine>
<Description>Phase One Installer from E Drive</Description> <Description>Phase One Installer from E Drive</Description>
<Order>3</Order> <Order>3</Order>

Binary file not shown.

View File

@ -1,12 +0,0 @@
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VMware, Inc.\VMnetLib\VMnetConfig\vmnet3]
"IPSubnetAddress"="192.168.199.0"
"IPSubnetMask"="255.255.255.0"
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VMware, Inc.\VMnetLib\VMnetConfig\vmnet3\Adapter]
"UseAdapter"=dword:00000001
"AdapterInstalled"=dword:00000001
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\VMware, Inc.\VMnetLib\VMnetConfig\vmnet3\DHCP]
"UseDHCP"=dword:00000001

8
SRC/Nested10/Build.cmd Normal file
View File

@ -0,0 +1,8 @@
@echo off
echo **
echo * Building on Windows 10
echo * Building on Windows 10 >> c:\buildlog.txt
cscript //B "%windir%\system32\slmgr.vbs" /ato
\\192.168.199.7\build\VMTools\setup64.exe /s /v "/qn"
pause
Exit

BIN
SRC/Nested10/Nested10.flp Normal file

Binary file not shown.

View File

@ -18,7 +18,7 @@
<InstallFrom> <InstallFrom>
<MetaData wcm:action="add"> <MetaData wcm:action="add">
<Key>/IMAGE/INDEX</Key> <Key>/IMAGE/INDEX</Key>
<Value>2</Value> <Value>1</Value>
</MetaData> </MetaData>
</InstallFrom> </InstallFrom>
</OSImage> </OSImage>
@ -45,39 +45,13 @@
</settings> </settings>
<settings pass="specialize"> <settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComputerName>dc</ComputerName> <ComputerName>Template10</ComputerName>
</component>
<component name="Microsoft-Windows-TCPIP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Interfaces>
<Interface wcm:action="add">
<Ipv4Settings>
<DhcpEnabled>false</DhcpEnabled>
<Metric>10</Metric>
<RouterDiscoveryEnabled>false</RouterDiscoveryEnabled>
</Ipv4Settings>
<UnicastIpAddresses>
<IpAddress wcm:action="add" wcm:keyValue="1">192.168.199.4/24</IpAddress>
</UnicastIpAddresses>
<Identifier>Local Area Connection</Identifier>
<Routes>
<Route wcm:action="add">
<Identifier>0</Identifier>
<Metric>10</Metric>
<NextHopAddress>192.168.199.2</NextHopAddress>
<Prefix>0.0.0.0/0</Prefix>
</Route>
</Routes>
</Interface>
</Interfaces>
</component> </component>
<component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DomainProfile_EnableFirewall>false</DomainProfile_EnableFirewall> <DomainProfile_EnableFirewall>false</DomainProfile_EnableFirewall>
<PrivateProfile_EnableFirewall>false</PrivateProfile_EnableFirewall> <PrivateProfile_EnableFirewall>false</PrivateProfile_EnableFirewall>
<PublicProfile_EnableFirewall>false</PublicProfile_EnableFirewall> <PublicProfile_EnableFirewall>false</PublicProfile_EnableFirewall>
</component> </component>
<component name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
</component>
<component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon> <DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
</component> </component>
@ -88,6 +62,16 @@
<IEHardenUser>false</IEHardenUser> <IEHardenUser>false</IEHardenUser>
<IEHardenAdmin>false</IEHardenAdmin> <IEHardenAdmin>false</IEHardenAdmin>
</component> </component>
<component name="Microsoft-Windows-TCPIP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Interfaces>
<Interface wcm:action="add">
<Ipv4Settings>
<DhcpEnabled>true</DhcpEnabled>
</Ipv4Settings>
<Identifier>1</Identifier>
</Interface>
</Interfaces>
</component>
</settings> </settings>
<settings pass="oobeSystem"> <settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
@ -102,48 +86,31 @@
</AutoLogon> </AutoLogon>
<FirstLogonCommands> <FirstLogonCommands>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>A:\Build.cmd</CommandLine> <CommandLine>a:\Build.cmd</CommandLine>
<Description>Phase One Installer from A Drive</Description> <Description>Phase One Installer</Description>
<Order>1</Order> <Order>1</Order>
<RequiresUserInput>true</RequiresUserInput> <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>D:\Build.cmd</CommandLine>
<Description>Phase One Installer from D Drive</Description>
<Order>2</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>E:\Build.cmd</CommandLine>
<Description>Phase One Installer from E Drive</Description>
<Order>3</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand> </SynchronousCommand>
</FirstLogonCommands> </FirstLogonCommands>
<OOBE> <OOBE>
<HideEULAPage>true</HideEULAPage> <HideEULAPage>true</HideEULAPage>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<NetworkLocation>Work</NetworkLocation> <NetworkLocation>Work</NetworkLocation>
<SkipMachineOOBE>true</SkipMachineOOBE>
<SkipUserOOBE>true</SkipUserOOBE>
<HideLocalAccountScreen>true</HideLocalAccountScreen>
<HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>
<HideOnlineAccountScreens>true</HideOnlineAccountScreens>
<UnattendEnableRetailDemo>false</UnattendEnableRetailDemo>
<ProtectYourPC>1</ProtectYourPC>
</OOBE> </OOBE>
<UserAccounts> <UserAccounts>
<AdministratorPassword> <AdministratorPassword>
<Value>VgBNAHcAYQByAGUAMQAhAEEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAUABhAHMAcwB3AG8AcgBkAA==</Value> <Value>VgBNAHcAYQByAGUAMQAhAEEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAUABhAHMAcwB3AG8AcgBkAA==</Value>
<PlainText>false</PlainText> <PlainText>false</PlainText>
</AdministratorPassword> </AdministratorPassword>
<LocalAccounts>
<LocalAccount wcm:action="add">
<Password>
<Value>VgBNAHcAYQByAGUAMQAhAFAAYQBzAHMAdwBvAHIAZAA=</Value>
<PlainText>false</PlainText>
</Password>
<Description>vSphere Administrator</Description>
<DisplayName>VI Admin</DisplayName>
<Group>Administrators</Group>
<Name>vi-admin</Name>
</LocalAccount>
</LocalAccounts>
</UserAccounts> </UserAccounts>
</component> </component>
</settings> </settings>
<cpi:offlineImage cpi:source="wim:d:/lab/win2k8r2sp1/sources/install.wim#Windows Server 2008 R2 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> <cpi:offlineImage cpi:source="catalog:d:/lab/windows/win10/sources/install_windows 10 enterprise evaluation technical preview.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend> </unattend>

Binary file not shown.

8
SRC/Nested7/Build.cmd Normal file
View File

@ -0,0 +1,8 @@
@echo off
echo **
echo * Building on Windows 7
echo * Building on Windows 7 >> c:\buildlog.txt
cscript //B "%windir%\system32\slmgr.vbs" /ato
\\192.168.199.7\build\VMTools\setup64.exe /s /v "/qn"
pause
Exit

BIN
SRC/Nested7/Nested7.flp Normal file

Binary file not shown.

View File

@ -0,0 +1,111 @@
<?xml version="1.0" encoding="utf-8"?>
<unattend xmlns="urn:schemas-microsoft-com:unattend">
<settings pass="windowsPE">
<component name="Microsoft-Windows-International-Core-WinPE" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<InputLocale>en-US</InputLocale>
<SystemLocale>en-US</SystemLocale>
<UILanguage>en-US</UILanguage>
<UILanguageFallback>en-US</UILanguageFallback>
<UserLocale>en-US</UserLocale>
</component>
<component name="Microsoft-Windows-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ImageInstall>
<OSImage>
<InstallTo>
<DiskID>0</DiskID>
<PartitionID>1</PartitionID>
</InstallTo>
<InstallFrom>
<MetaData wcm:action="add">
<Key>/IMAGE/INDEX</Key>
<Value>1</Value>
</MetaData>
</InstallFrom>
</OSImage>
</ImageInstall>
<UserData>
<AcceptEula>true</AcceptEula>
<FullName>Lab</FullName>
<Organization>Lab.local</Organization>
</UserData>
<DiskConfiguration>
<Disk wcm:action="add">
<CreatePartitions>
<CreatePartition wcm:action="add">
<Extend>true</Extend>
<Order>1</Order>
<Type>Primary</Type>
</CreatePartition>
</CreatePartitions>
<DiskID>0</DiskID>
<WillWipeDisk>true</WillWipeDisk>
</Disk>
</DiskConfiguration>
</component>
</settings>
<settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComputerName>Template7</ComputerName>
</component>
<component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DomainProfile_EnableFirewall>false</DomainProfile_EnableFirewall>
<PrivateProfile_EnableFirewall>false</PrivateProfile_EnableFirewall>
<PublicProfile_EnableFirewall>false</PublicProfile_EnableFirewall>
</component>
<component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
</component>
<component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fDenyTSConnections>false</fDenyTSConnections>
</component>
<component name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<IEHardenUser>false</IEHardenUser>
<IEHardenAdmin>false</IEHardenAdmin>
</component>
<component name="Microsoft-Windows-TCPIP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Interfaces>
<Interface wcm:action="add">
<Ipv4Settings>
<DhcpEnabled>true</DhcpEnabled>
</Ipv4Settings>
<Identifier>1</Identifier>
</Interface>
</Interfaces>
</component>
</settings>
<settings pass="oobeSystem">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AutoLogon>
<Password>
<Value>VgBNAHcAYQByAGUAMQAhAFAAYQBzAHMAdwBvAHIAZAA=</Value>
<PlainText>false</PlainText>
</Password>
<Enabled>true</Enabled>
<LogonCount>999</LogonCount>
<Username>administrator</Username>
</AutoLogon>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>a:\Build.cmd</CommandLine>
<Description>Phase One Installer</Description>
<Order>1</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>
<OOBE>
<HideEULAPage>true</HideEULAPage>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
<NetworkLocation>Work</NetworkLocation>
<SkipMachineOOBE>true</SkipMachineOOBE>
<SkipUserOOBE>true</SkipUserOOBE>
</OOBE>
<UserAccounts>
<AdministratorPassword>
<Value>VgBNAHcAYQByAGUAMQAhAEEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAUABhAHMAcwB3AG8AcgBkAA==</Value>
<PlainText>false</PlainText>
</AdministratorPassword>
</UserAccounts>
</component>
</settings>
<cpi:offlineImage cpi:source="catalog:c:/_source/win7/sources/install_windows 7 enterprise.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend>

8
SRC/Nested8/Build.cmd Normal file
View File

@ -0,0 +1,8 @@
@echo off
echo **
echo * Building on Windows 8
echo * Building on Windows 8 >> c:\buildlog.txt
cscript //B "%windir%\system32\slmgr.vbs" /ato
\\192.168.199.7\build\VMTools\setup64.exe /s /v "/qn"
pause
Exit

BIN
SRC/Nested8/Nested8.flp Normal file

Binary file not shown.

View File

@ -18,7 +18,7 @@
<InstallFrom> <InstallFrom>
<MetaData wcm:action="add"> <MetaData wcm:action="add">
<Key>/IMAGE/INDEX</Key> <Key>/IMAGE/INDEX</Key>
<Value>2</Value> <Value>1</Value>
</MetaData> </MetaData>
</InstallFrom> </InstallFrom>
</OSImage> </OSImage>
@ -45,79 +45,32 @@
</settings> </settings>
<settings pass="specialize"> <settings pass="specialize">
<component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<ComputerName>vc</ComputerName> <ComputerName>Template8</ComputerName>
</component>
<component name="Microsoft-Windows-TCPIP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Interfaces>
<Interface wcm:action="add">
<Ipv4Settings>
<DhcpEnabled>false</DhcpEnabled>
<Metric>10</Metric>
<RouterDiscoveryEnabled>false</RouterDiscoveryEnabled>
</Ipv4Settings>
<UnicastIpAddresses>
<IpAddress wcm:action="add" wcm:keyValue="1">192.168.199.5/24</IpAddress>
</UnicastIpAddresses>
<Identifier>Local Area Connection</Identifier>
<Routes>
<Route wcm:action="add">
<Identifier>0</Identifier>
<Metric>10</Metric>
<NextHopAddress>192.168.199.2</NextHopAddress>
<Prefix>0.0.0.0/0</Prefix>
</Route>
</Routes>
</Interface>
</Interfaces>
</component>
<component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Identification>
<Credentials>
<Domain>lab.local</Domain>
<Password>VMware1!</Password>
<Username>JoinUser</Username>
</Credentials>
<JoinDomain>lab.local</JoinDomain>
</Identification>
</component>
<component name="Microsoft-Windows-DNS-Client" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DNSSuffixSearchOrder>
<DomainName wcm:action="add" wcm:keyValue="1">lab.local</DomainName>
</DNSSuffixSearchOrder>
<Interfaces>
<Interface wcm:action="add">
<DNSServerSearchOrder>
<IpAddress wcm:action="add" wcm:keyValue="1">192.168.199.4</IpAddress>
</DNSServerSearchOrder>
<DisableDynamicUpdate>true</DisableDynamicUpdate>
<DNSDomain>lab.local</DNSDomain>
<EnableAdapterDomainNameRegistration>true</EnableAdapterDomainNameRegistration>
<Identifier>Local Area Connection</Identifier>
</Interface>
</Interfaces>
</component>
<component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
</component>
<component name="Microsoft-Windows-OutOfBoxExperience" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DoNotOpenInitialConfigurationTasksAtLogon>true</DoNotOpenInitialConfigurationTasksAtLogon>
</component> </component>
<component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <component name="Networking-MPSSVC-Svc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DomainProfile_EnableFirewall>false</DomainProfile_EnableFirewall> <DomainProfile_EnableFirewall>false</DomainProfile_EnableFirewall>
<PrivateProfile_EnableFirewall>false</PrivateProfile_EnableFirewall> <PrivateProfile_EnableFirewall>false</PrivateProfile_EnableFirewall>
<PublicProfile_EnableFirewall>false</PublicProfile_EnableFirewall> <PublicProfile_EnableFirewall>false</PublicProfile_EnableFirewall>
</component> </component>
<component name="Microsoft-Windows-ServerManager-SvrMgrNc" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<DoNotOpenServerManagerAtLogon>true</DoNotOpenServerManagerAtLogon>
</component>
<component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <component name="Microsoft-Windows-TerminalServices-LocalSessionManager" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<fDenyTSConnections>false</fDenyTSConnections> <fDenyTSConnections>false</fDenyTSConnections>
</component> </component>
<component name="Microsoft-Windows-IE-InternetExplorer" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<TrustedSites>https://*.lab.local;http://*.lab.local;http://v1</TrustedSites>
<DisableFirstRunWizard>true</DisableFirstRunWizard>
<DisableOOBAccelerators>true</DisableOOBAccelerators>
</component>
<component name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <component name="Microsoft-Windows-IE-ESC" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<IEHardenAdmin>false</IEHardenAdmin>
<IEHardenUser>false</IEHardenUser> <IEHardenUser>false</IEHardenUser>
<IEHardenAdmin>false</IEHardenAdmin>
</component>
<component name="Microsoft-Windows-TCPIP" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Interfaces>
<Interface wcm:action="add">
<Ipv4Settings>
<DhcpEnabled>true</DhcpEnabled>
</Ipv4Settings>
<Identifier>1</Identifier>
</Interface>
</Interfaces>
</component> </component>
</settings> </settings>
<settings pass="oobeSystem"> <settings pass="oobeSystem">
@ -128,9 +81,17 @@
<PlainText>false</PlainText> <PlainText>false</PlainText>
</Password> </Password>
<Enabled>true</Enabled> <Enabled>true</Enabled>
<LogonCount>99</LogonCount> <LogonCount>999</LogonCount>
<Username>vc\Administrator</Username> <Username>administrator</Username>
</AutoLogon> </AutoLogon>
<FirstLogonCommands>
<SynchronousCommand wcm:action="add">
<CommandLine>a:\Build.cmd</CommandLine>
<Description>Phase One Installer</Description>
<Order>1</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>
<OOBE> <OOBE>
<HideEULAPage>true</HideEULAPage> <HideEULAPage>true</HideEULAPage>
<HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE> <HideWirelessSetupInOOBE>true</HideWirelessSetupInOOBE>
@ -142,27 +103,10 @@
<PlainText>false</PlainText> <PlainText>false</PlainText>
</AdministratorPassword> </AdministratorPassword>
</UserAccounts> </UserAccounts>
<FirstLogonCommands> <BluetoothTaskbarIconEnabled>false</BluetoothTaskbarIconEnabled>
<SynchronousCommand wcm:action="add"> <DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet>
<CommandLine>A:\Build.cmd</CommandLine> <ShowWindowsLive>false</ShowWindowsLive>
<Description>Phase One Installer from A Drive</Description>
<Order>1</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>D:\Build.cmd</CommandLine>
<Description>Phase One Installer from D Drive</Description>
<Order>2</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>E:\Build.cmd</CommandLine>
<Description>Phase One Installer from E Drive</Description>
<Order>3</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
</FirstLogonCommands>
</component> </component>
</settings> </settings>
<cpi:offlineImage cpi:source="wim:d:/lab/win2k8r2sp1/sources/install.wim#Windows Server 2008 R2 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi" /> <cpi:offlineImage cpi:source="catalog:d:/lab/windows/win8/sources/install_windows 8.1 pro.clg" xmlns:cpi="urn:schemas-microsoft-com:cpi" />
</unattend> </unattend>

Binary file not shown.

View File

@ -18,7 +18,7 @@
<InstallFrom> <InstallFrom>
<MetaData wcm:action="add"> <MetaData wcm:action="add">
<Key>/IMAGE/INDEX</Key> <Key>/IMAGE/INDEX</Key>
<Value>1</Value> <Value>2</Value>
</MetaData> </MetaData>
</InstallFrom> </InstallFrom>
</OSImage> </OSImage>
@ -130,10 +130,22 @@
</UserAccounts> </UserAccounts>
<FirstLogonCommands> <FirstLogonCommands>
<SynchronousCommand wcm:action="add"> <SynchronousCommand wcm:action="add">
<CommandLine>a:\Build.cmd</CommandLine> <CommandLine>A:\Build.cmd</CommandLine>
<Description>Build</Description> <Description>Phase One Installer from A Drive</Description>
<Order>1</Order> <Order>1</Order>
<RequiresUserInput>true</RequiresUserInput> <RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>D:\Build.cmd</CommandLine>
<Description>Phase One Installer from D Drive</Description>
<Order>2</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand>
<SynchronousCommand wcm:action="add">
<CommandLine>E:\Build.cmd</CommandLine>
<Description>Phase One Installer from E Drive</Description>
<Order>3</Order>
<RequiresUserInput>true</RequiresUserInput>
</SynchronousCommand> </SynchronousCommand>
</FirstLogonCommands> </FirstLogonCommands>
</component> </component>

View File

@ -6,27 +6,21 @@ ver | find "6.2" > nul
if %ERRORLEVEL% == 0 goto ver_2K12 if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "6.3" > nul ver | find "6.3" > nul
if %ERRORLEVEL% == 0 goto ver_2K12 if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "10.0" > nul
if %ERRORLEVEL% == 0 goto ver_2K16
goto RunBuild goto RunBuild
:ver_2K8 :ver_2K8
goto RunBuild goto RunBuild
:ver_2K12 :ver_2K12
:ver_2K16
netsh interface ip set address name="Ethernet" static 192.168.199.35 255.255.255.0 192.168.199.2 1 netsh interface ip set address name="Ethernet" static 192.168.199.35 255.255.255.0 192.168.199.2 1
netsh interface ip set address name="Ethernet0" static 192.168.199.35 255.255.255.0 192.168.199.2 1
ping 192.168.199.2
netsh interface ip set dnsservers name="Ethernet" static address=192.168.199.4 primary netsh interface ip set dnsservers name="Ethernet" static address=192.168.199.4 primary
netsh interface ip set dnsservers name="Ethernet0" static address=192.168.199.4 primary
Dism /online /enable-feature /featurename:NetFx3ServerFeatures Dism /online /enable-feature /featurename:NetFx3ServerFeatures
Dism /online /enable-feature /featurename:NetFx3 /source:D:\Sources\sxs Dism /online /enable-feature /featurename:NetFx3 /source:D:\Sources\sxs
copy \\192.168.199.7\Build\Automate\DC\ocsetup.exe c:\windows\system32\ copy \\192.168.199.7\Build\Automate\DC\ocsetup.exe c:\windows\system32\
echo * Mount Install Image
echo * Mount Install Image >> c:\buildlog.txt
mkdir c:\mountdir
Dism /mount-wim /WimFile:D:\sources\install.wim /Index:2 /MountDir:c:\mountdir /readonly /quiet
echo * Setup recall of build script
copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\
type \\192.168.199.7\Build\Automate\version.txt >> c:\buildlog.txt
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /t REG_SZ /d "cmd /c c:\build.cmd" /f >> c:\buildlog.txt
echo * Install GUI onto Server Core
echo * Install GUI onto Server Core >> c:\buildlog.txt
Dism /online /enable-feature /featurename:server-gui-shell /all /source:c:\mountdir\windows\winsxs /quiet
Pause
goto RunBuild goto RunBuild
:RunBuild :RunBuild
copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\ copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\

Binary file not shown.

View File

@ -1,4 +1,6 @@
@echo off @echo off
echo * Starting build.cmd
echo * Starting build.cmd >> c:\buildlog.txt
type \\192.168.199.7\Build\Automate\version.txt >> c:\buildlog.txt type \\192.168.199.7\Build\Automate\version.txt >> c:\buildlog.txt
ver | find "6.1" > nul ver | find "6.1" > nul
if %ERRORLEVEL% == 0 goto ver_2K8 if %ERRORLEVEL% == 0 goto ver_2K8
@ -6,17 +8,26 @@ ver | find "6.2" > nul
if %ERRORLEVEL% == 0 goto ver_2K12 if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "6.3" > nul ver | find "6.3" > nul
if %ERRORLEVEL% == 0 goto ver_2K12 if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "10.0" > nul
if %ERRORLEVEL% == 0 goto ver_2K16
goto RunBuild goto RunBuild
:ver_2K8 :ver_2K8
goto RunBuild
:ver_2K12
echo ** echo **
echo * Building on Windows 2012 echo * Building on Windows 2008 core
echo * Building on Windows 2012 >> c:\buildlog.txt echo * Building on Windows 2008 core >> c:\buildlog.txt
DISM.exe /online /enable-feature /featurename:NetFx2-ServerCore >> c:\buildlog.txt
DISM.exe /online /enable-feature /featurename:NetFx3-ServerCore >> c:\buildlog.txt
DISM.exe /online /enable-feature /featurename:NetFx2-ServerCore-WOW64 >> c:\buildlog.txt
DISM.exe /online /enable-feature /featurename:NetFx3-ServerCore-WOW64 >> c:\buildlog.txt
DISM.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShell >> c:\buildlog.txt
DISM.exe /online /enable-feature /featurename:MicrosoftWindowsPowerShell-WOW64 >> c:\buildlog.txt
echo * Set IP address echo * Set IP address
echo * Set IP address >> c:\buildlog.txt echo * Set IP address >> c:\buildlog.txt
netsh interface ip set address "Ethernet" static 192.168.199.5 255.255.255.0 192.168.199.2 1 netsh interface ip set address "Ethernet" static 192.168.199.5 255.255.255.0 192.168.199.2 1
netsh interface ip set address "Ethernet0" static 192.168.199.5 255.255.255.0 192.168.199.2 1
ping 192.168.199.2
netsh interface ip set dnsservers "Ethernet" static 192.168.199.4 primary netsh interface ip set dnsservers "Ethernet" static 192.168.199.4 primary
netsh interface ip set dnsservers "Ethernet0" static 192.168.199.4 primary
echo * Install .Net 3 echo * Install .Net 3
echo * Install .Net 3 >> c:\buildlog.txt echo * Install .Net 3 >> c:\buildlog.txt
Dism /online /enable-feature /featurename:NetFx3ServerFeatures /quiet Dism /online /enable-feature /featurename:NetFx3ServerFeatures /quiet
@ -26,23 +37,34 @@ echo * Install Setup recall of build script
echo * Install Setup recall of build script >> c:\buildlog.txt echo * Install Setup recall of build script >> c:\buildlog.txt
copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\ copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f >> c:\buildlog.txt reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f >> c:\buildlog.txt
echo * Mount Install Image shutdown -r -t 1
echo * Mount Install Image >> c:\buildlog.txt exit
mkdir c:\mountdir :ver_2K12
If Exist D:\sources\install.wim Dism /mount-wim /WimFile:D:\sources\install.wim /Index:2 /MountDir:c:\mountdir /readonly /quiet echo **
If Exist E:\sources\install.wim Dism /mount-wim /WimFile:E:\sources\install.wim /Index:2 /MountDir:c:\mountdir /readonly /quiet echo * Building on Windows 2012
echo * Install GUI onto Server Core echo * Building on Windows 2012 >> c:\buildlog.txt
echo * Install GUI onto Server Core >> c:\buildlog.txt goto StartBuild
Dism /online /enable-feature /featurename:server-gui-mgmt /all /source:c:\mountdir\windows\winsxs /quiet /norestart :ver_2K16
Dism /online /enable-feature /featurename:server-gui-shell /all /source:c:\mountdir\windows\winsxs /quiet /norestart echo **
Dism /online /enable-feature /featurename:servercore-fullserver /all /source:c:\mountdir\windows\winsxs /quiet /norestart echo * Building on Windows 2012
echo * Install Media Foundation echo * Building on Windows 2012 >> c:\buildlog.txt
echo * Install Media Foundation >> c:\buildlog.txt goto StartBuild
Dism /online /enable-feature /featurename:ServerMediaFoundation /all /source:c:\mountdir\windows\winsxs /quiet /norestart :StartBuild
echo * Install Desktop Experience echo * Set IP address
echo * Install Desktop Experience >> c:\buildlog.txt echo * Set IP address >> c:\buildlog.txt
Dism /online /enable-feature /featurename:DesktopExperience /all /source:c:\mountdir\windows\winsxs /quiet netsh interface ip set address "Ethernet" static 192.168.199.5 255.255.255.0 192.168.199.2 1
pause netsh interface ip set address "Ethernet0" static 192.168.199.5 255.255.255.0 192.168.199.2 1
ping 192.168.199.2
netsh interface ip set dnsservers "Ethernet" static 192.168.199.4 primary
netsh interface ip set dnsservers "Ethernet0" static 192.168.199.4 primary
echo * Install .Net 3
echo * Install .Net 3 >> c:\buildlog.txt
Dism /online /enable-feature /featurename:NetFx3ServerFeatures /quiet
Dism /online /enable-feature /featurename:NetFx3 /source:D:\Sources\sxs /quiet
copy \\192.168.199.7\Build\Automate\DC\ocsetup.exe c:\windows\system32\
echo * Install Setup recall of build script
echo * Install Setup recall of build script >> c:\buildlog.txt
goto RunBuild
:RunBuild :RunBuild
copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\ copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\
c:\build.cmd c:\build.cmd

View File

@ -1,49 +0,0 @@
@echo off
type \\192.168.199.7\Build\Automate\version.txt >> c:\buildlog.txt
ver | find "6.1" > nul
if %ERRORLEVEL% == 0 goto ver_2K8
ver | find "6.2" > nul
if %ERRORLEVEL% == 0 goto ver_2K12
ver | find "6.3" > nul
if %ERRORLEVEL% == 0 goto ver_2K12
goto RunBuild
:ver_2K8
goto RunBuild
:ver_2K12
echo **
echo * Building on Windows 2012
echo * Building on Windows 2012 >> c:\buildlog.txt
echo * Set IP address
echo * Set IP address >> c:\buildlog.txt
netsh interface ip set address "Ethernet" static 192.168.199.5 255.255.255.0 192.168.199.2 1
netsh interface ip set dnsservers "Ethernet" static 192.168.199.4 primary
echo * Install .Net 3
echo * Install .Net 3 >> c:\buildlog.txt
Dism /online /enable-feature /featurename:NetFx3ServerFeatures /quiet
Dism /online /enable-feature /featurename:NetFx3 /source:D:\Sources\sxs /quiet
copy \\192.168.199.7\Build\Automate\DC\ocsetup.exe c:\windows\system32\
echo * Install Setup recall of build script
echo * Install Setup recall of build script >> c:\buildlog.txt
copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\
reg add HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\RunOnce /v Build /t REG_SZ /d "cmd /c c:\Build.cmd" /f >> c:\buildlog.txt
echo * Mount Install Image
echo * Mount Install Image >> c:\buildlog.txt
mkdir c:\mountdir
If Exist D:\sources\install.wim Dism /mount-wim /WimFile:D:\sources\install.wim /Index:2 /MountDir:c:\mountdir /readonly /quiet
If Exist E:\sources\install.wim Dism /mount-wim /WimFile:E:\sources\install.wim /Index:2 /MountDir:c:\mountdir /readonly /quiet
echo * Install GUI onto Server Core
echo * Install GUI onto Server Core >> c:\buildlog.txt
Dism /online /enable-feature /featurename:server-gui-mgmt /all /source:c:\mountdir\windows\winsxs /quiet /norestart
Dism /online /enable-feature /featurename:server-gui-shell /all /source:c:\mountdir\windows\winsxs /quiet /norestart
Dism /online /enable-feature /featurename:servercore-fullserver /all /source:c:\mountdir\windows\winsxs /quiet /norestart
echo * Install Media Foundation
echo * Install Media Foundation >> c:\buildlog.txt
Dism /online /enable-feature /featurename:ServerMediaFoundation /all /source:c:\mountdir\windows\winsxs /quiet /norestart
echo * Install Desktop Experience
echo * Install Desktop Experience >> c:\buildlog.txt
Dism /online /enable-feature /featurename:DesktopExperience /all /source:c:\mountdir\windows\winsxs /quiet
pause
:RunBuild
copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\
c:\build.cmd
Exit

Binary file not shown.

Binary file not shown.

View File

@ -18,7 +18,7 @@
<InstallFrom> <InstallFrom>
<MetaData wcm:action="add"> <MetaData wcm:action="add">
<Key>/IMAGE/INDEX</Key> <Key>/IMAGE/INDEX</Key>
<Value>1</Value> <Value>2</Value>
</MetaData> </MetaData>
</InstallFrom> </InstallFrom>
</OSImage> </OSImage>

Binary file not shown.

View File

@ -1,53 +0,0 @@
#!/bin/sh
. /etc/rc.subr
name="BuildPop"
start_cmd="${name}_start"
stop_cmd=":"
BuildPop_start()
{
mkdir /mnt/cd0
mount_cd9660 /dev/cd0 /mnt/cd0
mkdir /mnt/cd1
mount_cd9660 /dev/cd1 /mnt/cd1
if [ -f "/mnt/LABVOL/Build/ESXi60/vmware-esx-base-readme" ]
then
echo "Already have ESXi 6.0 installer"
else
if [ -f "/mnt/cd0/vmware-esx-base-readme" ]
then
echo "Found ESXi installer on CD0"
cp -r /mnt/cd0/* /mnt/LABVOL/Build/ESXi60
fi
if [ -f "/mnt/cd1/vmware-esx-base-readme" ]
then
echo "Found ESXi installer on CD1"
cp -r /mnt/cd1/* /mnt/LABVOL/Build/ESXi60
fi
fi
if [ -f "/mnt/LABVOL/Build/VIM_60/autorun.exe" ]
then
echo "Already have vCentre 6.0 installer"
else
if [ -f "/mnt/cd0/autorun.exe" ]
then
echo "Found vCentre installer on CD0"
cp -r /mnt/cd0/* /mnt/LABVOL/Build/VIM_60
else
fi
if [ -f "/mnt/cd1/autorun.exe" ]
then
echo "Found vCentre installer on CD1"
cp -r /mnt/cd1/* /mnt/LABVOL/Build/VIM_60
else
fi
fi
}
load_rc_config $name
run_rc_command "$1"