diff --git a/Build/Automate/AddHosts.ps1 b/Build/Automate/AddHosts.ps1 index 863d43d..17fbdd5 100644 --- a/Build/Automate/AddHosts.ps1 +++ b/Build/Automate/AddHosts.ps1 @@ -11,22 +11,11 @@ if (Test-Path C:\PSFunctions.ps1) { Read-Host "Press to 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 to exit" -# exit -#} $a = (Get-Host).UI.RawUI $b = $a.WindowSize $b.Height = $a.MaxWindowSize.Height -1 $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] If ($Subnet -eq "199") { @@ -44,18 +33,18 @@ If ($Subnet -eq "201") { $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." do { Start-Sleep -Seconds 30 } 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." Read-Host "Press to 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 { Write-BuildLog "Loading PowerCLI plugin, this may take a little while." Add-PSSnapin VMware.VimAutomation.Core @@ -65,6 +54,10 @@ if ((Get-PSSnapin -Name VMware.VimAutomation.Core -ErrorAction SilentlyContinue) Read-Host "Press to 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++) { $vmhost = "$HostPrefix$i.lab.local" @@ -77,11 +70,10 @@ for ($i=1;$i -le 4; $i++) { } } 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" Exit } -Write-BuildLog " " If (!(Test-Path "B:\*")) { Net use B: \\nas\Build} if (Test-Path "B:\Automate\automate.ini") { 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() if ($createds -like "true") { $createds = $true - Write-BuildLog " Datastores will be built and added to vCenter." + Write-BuildLog "Datastores will be built and added to vCenter." } else { $createds = $false } if ($createvm -like "true") { $createvm = $true $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 { $createvm = $false } if ($createxp -like "true") { $createxp = $true $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 { $createxp = $false } @@ -196,9 +188,7 @@ for ($i=1;$i -le $MaxHosts; $i++) { } Start-Sleep 5 While ((Get-VMHost $VMHost).ConnectionState -ne "Connected"){ - Write-BuildLog " " Write-BuildLog $VMHost " is not yet connected. Pausing for 5 seconds." - Write-BuildLog " " Start-Sleep 5 } $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." $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 = @() for ($i=1;$i -le $MaxHosts; $i++) {$PingStatus +=$True} do { @@ -291,7 +281,7 @@ do { If ($PingStatus[$I-1] -eq $True) {$StayHere = $True} } } while ($StayHere) -Write-Host "Wait until all hosts are pinging" +Write-BuildLog "Wait until all hosts are pinging" do { Start-Sleep -Seconds 1 $ping = new-object System.Net.NetworkInformation.Ping @@ -306,7 +296,7 @@ do { If ($PingStatus[$I-1] -eq $False) {$StayHere = $True} } } 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} do { Start-Sleep -Seconds 1 @@ -321,7 +311,7 @@ do { If ($PingStatus[$I-1] -eq $False) {$StayHere = $True} } } 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 If ($SRM -ne $True){ 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 $null = $Cluster.ReconfigureComputeResource_Task($spec, $true) Write-BuildLog "Waiting two minutes for HA to complete configuration." + $Datastore = Get-Datastore -VMhost $vmHost -name "NFS01" 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 - $VMName="Template2012" - if (($CreateVM) -and ((Get-VM -name $VMName -ErrorAction "SilentlyContinue") -eq $null ) -and (test-path "\\192.168.199.7\build\Win2012.ISO")) { - $Datastore = Get-Datastore -VMhost $vmHost -name "NFS01" - Start-Sleep -Seconds 2 - if (!(Get-PSDrive -Name NFS01 -ErrorAction "SilentlyContinue")) { - $null = New-PSDrive -Name NFS01 -PSProvider ViMdatastore -Root '\' -Location $Datastore - } - #Create new VM if existing VM or template doesn't exist - if (!(Test-Path NFS01:\$VMName\$VMName.vmdk)) { - Write-BuildLog "Creating Template2012 VM as Windows Server 2012" - If ((Get-vmhost)[0].version -lt "5.5.0"){ - $MyVM = New-VM -Name $VMName -VMhost $vmHost -datastore $Datastore -NumCPU 1 -MemoryMB 768 -DiskMB 16384 -DiskStorageFormat Thin -GuestID windows8Server64Guest - get-networkadapter $MyVM |set-networkadapter -type e1000 -confirm:$false - } Else { - $MyVM = New-VM -Name $VMName -VMhost $vmHost -datastore $Datastore -NumCPU 1 -MemoryMB 768 -DiskMB 16384 -DiskStorageFormat Thin -GuestID windows8Server64Guest -Version "v8" - } - $null = New-CDDrive -VM $MyVM -ISOPath "[Build] /Win2012.ISO" -StartConnected - $null = New-FloppyDrive -VM $MyVM -FloppyImagePath "[Build] Automate/BootFloppies/Nested2012.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) - Write-BuildLog "Powering on VM and installing Windows." - $null = Start-VM $MyVM - } else { - Write-BuildLog "Found existing WinTemplate." - if (Test-Path NFS01:\$VMName\$VMName.vmtx) { - Write-BuildLog "Registering existing Template2012 template." - $vmxFile = Get-Item NFS01:\$VMName\$VMName.vmtx - $null = New-Template -VMHost $VMHost -TemplateFilePath $vmxFile.DatastoreFullPath - Write-BuildLog "Existing WinTemplate Template added to inventory." + $HostVer = (([int]((($VMHostObj.Version.Split("."))[0])) *10) + [int]($VMHostObj.Version.Split("."))[1]) + foreach ($os in ("2016","2012", "2008", "2K3", "10", "8", "7", "XP")){ + $VMName=("Template" + $OS) + if (($CreateVM) -and ((Get-VM -name $VMName -ErrorAction "SilentlyContinue") -eq $null ) -and (test-path ("\\192.168.199.7\build\Win" + $OS + ".iso"))) { + #Create new VM if existing VM or template doesn't exist + if (!(Test-Path NFS01:\$VMName\$VMName.vmdk)) { + $Go = $False + Switch ($OS) { + "2016" { + $GuestID = "windows9Server64Guest" + $GuestRAM = 768 + $GuestHDD = 16384 + $GuestMinHost = 60 + $GuestMaxHost = 99 + if (($HostVer -ge $GuestMinHost) -and ($HostVer -le $GuestMaxHost)) { + $Go = $True + $VMHWVer = "v11" + } + }"2012" { + $GuestID = "windows8Server64Guest" + $GuestRAM = 768 + $GuestHDD = 16384 + $GuestMinHost = 50 + $GuestMaxHost = 99 + if (($HostVer -ge $GuestMinHost) -and ($HostVer -le $GuestMaxHost)) { + $Go = $True + $VMHWVer = "v8" + } + } "2008" { + $GuestID = "windows7Server64Guest" + $GuestRAM = 768 + $GuestHDD = 16384 + $GuestMinHost = 40 + $GuestMaxHost = 99 + if (($HostVer -ge $GuestMinHost) -and ($HostVer -le $GuestMaxHost)) { + $Go = $True + $VMHWVer = "v7" + } + } "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" if ((Get-VM -name $VMName -ErrorAction "SilentlyContinue") -eq $null ) { Write-BuildLog "Registering existing tiny TTYLinux VM." @@ -526,10 +529,6 @@ If ($SRM -ne $True){ $null = Remove-PSDrive iSCSI3 } } -Write-BuildLog " " $null = Disconnect-VIServer -Server * -confirm:$false -if (Test-Path "C:\Program Files\VMware\VMware Tools\VMwareToolboxCmd.exe") { - Read-Host " Configuration complete, press to continue." -} -exit +#Read-Host " All OK?" diff --git a/Build/Automate/BootFloppies/CS1.flp b/Build/Automate/BootFloppies/CS1.flp deleted file mode 100644 index 1a89be1..0000000 Binary files a/Build/Automate/BootFloppies/CS1.flp and /dev/null differ diff --git a/Build/Automate/BootFloppies/CS2.flp b/Build/Automate/BootFloppies/CS2.flp deleted file mode 100644 index c2b17eb..0000000 Binary files a/Build/Automate/BootFloppies/CS2.flp and /dev/null differ diff --git a/Build/Automate/BootFloppies/Nested10.flp b/Build/Automate/BootFloppies/Nested10.flp new file mode 100644 index 0000000..07ce9d1 Binary files /dev/null and b/Build/Automate/BootFloppies/Nested10.flp differ diff --git a/SRC/DC/DC.flp b/Build/Automate/BootFloppies/Nested2008.flp similarity index 99% rename from SRC/DC/DC.flp rename to Build/Automate/BootFloppies/Nested2008.flp index 58ffc29..ba19a04 100644 Binary files a/SRC/DC/DC.flp and b/Build/Automate/BootFloppies/Nested2008.flp differ diff --git a/Build/Automate/BootFloppies/Nested2012.flp b/Build/Automate/BootFloppies/Nested2012.flp index 998dc72..df174f4 100644 Binary files a/Build/Automate/BootFloppies/Nested2012.flp and b/Build/Automate/BootFloppies/Nested2012.flp differ diff --git a/Build/Automate/BootFloppies/DC.flp b/Build/Automate/BootFloppies/Nested2016.flp similarity index 99% rename from Build/Automate/BootFloppies/DC.flp rename to Build/Automate/BootFloppies/Nested2016.flp index 3a31f93..95100e3 100644 Binary files a/Build/Automate/BootFloppies/DC.flp and b/Build/Automate/BootFloppies/Nested2016.flp differ diff --git a/Build/Automate/BootFloppies/Nested7.flp b/Build/Automate/BootFloppies/Nested7.flp new file mode 100644 index 0000000..1654b4c Binary files /dev/null and b/Build/Automate/BootFloppies/Nested7.flp differ diff --git a/SRC/DC.flp b/Build/Automate/BootFloppies/Nested8.flp similarity index 99% rename from SRC/DC.flp rename to Build/Automate/BootFloppies/Nested8.flp index 54c3742..8ed4d26 100644 Binary files a/SRC/DC.flp and b/Build/Automate/BootFloppies/Nested8.flp differ diff --git a/Build/Automate/BootFloppies/SS.flp b/Build/Automate/BootFloppies/SS.flp deleted file mode 100644 index 74fd88c..0000000 Binary files a/Build/Automate/BootFloppies/SS.flp and /dev/null differ diff --git a/Build/Automate/BootFloppies/freesco.flp b/Build/Automate/BootFloppies/freesco.flp deleted file mode 100644 index d7c9649..0000000 Binary files a/Build/Automate/BootFloppies/freesco.flp and /dev/null differ diff --git a/Build/Automate/CS1/Build.cmd b/Build/Automate/CS1/Build.cmd index a3516a2..1a6250a 100644 --- a/Build/Automate/CS1/Build.cmd +++ b/Build/Automate/CS1/Build.cmd @@ -1,10 +1,10 @@ @echo off 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 -net use B: \\192.168.199.7\Build >> 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\NoSCRNSave.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 "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 +copy B:\automate\_Common\wasp.dll C:\windows\system32 echo * Activate Windows >> c:\buildlog.txt cscript //B "%windir%\system32\slmgr.vbs" /ato 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:\ echo * Starting PowerShell script for Phase 2 completion echo * Starting PowerShell script for Phase 2 completion >> C:\buildlog.txt powershell c:\Build.ps1 -if exist C:\Build.ps1 del c:\Build.ps1 \ No newline at end of file diff --git a/Build/Automate/CS1/Build.ps1 b/Build/Automate/CS1/Build.ps1 index 29ac73d..726b372 100644 --- a/Build/Automate/CS1/Build.ps1 +++ b/Build/Automate/CS1/Build.ps1 @@ -6,30 +6,56 @@ if (Test-Path C:\PSFunctions.ps1) { 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") { 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." $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" $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) - } -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." - 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" set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0 Write-BuildLog "Install admin tools" Add-WindowsFeature RSAT-Feature-Tools,RSAT-DHCP,RSAT-DNS-Server,RSAT-AD-AdminCenter - Write-BuildLog "Enable remote management through firewall" - Netsh firewall set service RemoteAdmin - Netsh advfirewall set currentprofile settings remotemanagement enable + 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 } - +do { + start-sleep 10 +} until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null) $Files = get-childitem "b:\view$viewinstall" for ($i=0; $i -lt $files.Count; $i++) { If ($Files[$i].Name -like "VMware-viewconnectionserver*") {$Installer = $Files[$i].FullName} @@ -38,68 +64,82 @@ Switch ($ViewInstall) { 50 { Write-BuildLog "Install View 5.0 Connection Server" 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 - copy b:\automate\ViewSetup.ps1 c:\ - start-sleep 60 - %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe c:\ViewSetup.ps1 >> c:\buildlog.txt + C:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe "C:\Program Files\VMware\VMware View\Server\bin\PowershellServiceCmdlets.dll" } 51 { 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"' - 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 { 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"' - 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 { 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"' - 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 { Write-BuildLog "Install View 6.0 Connection Server" 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"' - 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 { Write-BuildLog "Install View 7.0 Connection Server" 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"' - 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" + $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" -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 Write-BuildLog "Install VMware Tools" 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" - $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" diff --git a/Build/Automate/CS1/ConfigView.ps1 b/Build/Automate/CS1/ConfigView.ps1 new file mode 100644 index 0000000..dd61fab --- /dev/null +++ b/Build/Automate/CS1/ConfigView.ps1 @@ -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" + $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" \ No newline at end of file diff --git a/Build/Automate/CS2/Build.cmd b/Build/Automate/CS2/Build.cmd index 189e38e..0b90e92 100644 --- a/Build/Automate/CS2/Build.cmd +++ b/Build/Automate/CS2/Build.cmd @@ -1,10 +1,12 @@ @echo off 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 -net use B: \\192.168.199.7\Build >> c:\buildlog.txt -type b:\automate\version.txt >> c:\buildlog.txt +echo * Connect to build share >> 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\NoSCRNSave.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 "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Attachments " /V SaveZoneInformation /T REG_DWORD /D 1 /F echo * Activate Windows >> c:\buildlog.txt +copy B:\automate\_Common\wasp.dll C:\windows\system32 cscript //B "%windir%\system32\slmgr.vbs" /ato +copy B:\Automate\validate.ps1 C:\ copy B:\Automate\PSFunctions.ps1 C:\ copy B:\Automate\%computername%\Build.ps1 c:\ echo * Starting PowerShell script for Phase 2 completion diff --git a/Build/Automate/CS2/Build.ps1 b/Build/Automate/CS2/Build.ps1 index 77ff9db..51093a7 100644 --- a/Build/Automate/CS2/Build.ps1 +++ b/Build/Automate/CS2/Build.ps1 @@ -5,6 +5,13 @@ if (Test-Path C:\PSFunctions.ps1) { Read-Host "Press to 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") { 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) $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." Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs Write-BuildLog "Disabling screen saver" set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0 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" Netsh firewall set service RemoteAdmin 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} } 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" 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 { 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"' - 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{ 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"' - 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 { 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"' - 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 { 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"' - 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 { 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"' - 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 + 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" + $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 } -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 @@ -80,32 +131,15 @@ route add 192.168.201.0 mask 255.255.255.0 192.168.199.254 -p 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 administrator CS2 $AdminPWD Write-BuildLog "Copy Connection server install and setup recall" $Files = get-childitem "b:\view$viewinstall" for ($i=0; $i -lt $files.Count; $i++) { If ($Files[$i].Name -like "VMware-viewconnectionserver*") {$Installer = $Files[$i].FullName} } 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" 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" - $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?" diff --git a/Build/Automate/DC/Phase2.cmd b/Build/Automate/DC/Phase2.cmd index 1edfa02..4a6782b 100644 --- a/Build/Automate/DC/Phase2.cmd +++ b/Build/Automate/DC/Phase2.cmd @@ -1,4 +1,6 @@ @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 ver | find "6.1" > nul if %ERRORLEVEL% == 0 goto ver_2K8 @@ -6,36 +8,21 @@ ver | find "6.2" > nul if %ERRORLEVEL% == 0 goto ver_2K12 ver | find "6.3" > nul if %ERRORLEVEL% == 0 goto ver_2K12 +ver | find "10.0" > nul +if %ERRORLEVEL% == 0 goto ver_2K16 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 +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 * Connect to build share echo * Connect to build share >> c:\buildlog.txt -net use B: \\192.168.199.7\Build -type B:\automate\version.txt >> C:\buildlog.txt +net use b: \\192.168.199.7\Build echo ** echo * Copy PowerShell files 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 >> C:\buildlog.txt powershell c:\Phase2.ps1 -if exist C:\phase2.ps1 del c:\phase2.ps1 -if exist c:\phase2.cmd del c:\phase2.cmd \ No newline at end of file +exit diff --git a/Build/Automate/DC/Phase2.ps1 b/Build/Automate/DC/Phase2.ps1 index 0b6df8e..d5f0472 100644 --- a/Build/Automate/DC/Phase2.ps1 +++ b/Build/Automate/DC/Phase2.ps1 @@ -6,6 +6,31 @@ if (Test-Path C:\PSFunctions.ps1) { 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 if (Test-Path B:\Automate\automate.ini) { $KMSIP = "0.0.0.0" @@ -45,13 +70,12 @@ if (Test-Path B:\Automate\automate.ini) { Write-BuildLog "Installing 7-zip." 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." } catch { Write-BuildLog "7-zip installation failed." } -Write-BuildLog "" if (Test-Path "b:\VMware-PowerCLI.exe") { $PowCLIver = (Get-ChildItem B:\VMware-PowerCLI.exe).VersionInfo.ProductVersion.trim() 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." xcopy B:\Automate\DC\TFTP-Root\*.* C:\TFTP-Root\ /s /c /y /q Write-BuildLog "Installation of TFTP completed." - Write-BuildLog "" } 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 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\*.iso") -and !(Test-Path "B:\ESXi60\BOOT.CFG") ){ 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" 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" - 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 Write-BuildLog "ESXi 6.0 added to TFTP and PXE menu." - Write-BuildLog "" $esxi60 = $true } else { $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" 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" - 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 Write-BuildLog "ESXi 5.5 added to TFTP and PXE menu." - Write-BuildLog "" $esxi55 = $true } else { $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" 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" - 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 Write-BuildLog "ESXi 5.1 added to TFTP and PXE menu." - Write-BuildLog "" $esxi51 = $true } else { $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" 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" - 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 Write-BuildLog "ESXi 5.0 added to TFTP and PXE menu." - Write-BuildLog "" $esxi50 = $true } else { $esxi50 = $false @@ -215,7 +282,6 @@ if (Test-Path "B:\ESXi41\*") { xcopy B:\ESXi41\mboot.c32 C:\TFTP-Root\ESXi41 /s /c /y /q powershell C:\PXEMenuConfig.ps1 ESXi41 Write-BuildLog "ESXi 4.1 added to TFTP and PXE menu." - Write-BuildLog "" $esxi41 = $true } else { $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 powershell C:\PXEMenuConfig.ps1 ESX41 Write-BuildLog "ESX 4.1 added to TFTP and PXE menu." - Write-BuildLog "" $esx41 = $true } else { $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 "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." @@ -254,16 +319,39 @@ if (Test-Path "B:\gParted\*") { LABEL gParted MENU LABEL gParted utility 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..." +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\*.iso") -and !(Test-Path "B:\VIM_60\autorun.exe")){ 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." $vCenter60 = $true } else { @@ -272,7 +360,8 @@ if (Test-Path "B:\VIM_60\*") { if (Test-Path "B:\VIM_55\*") { if ((Test-Path "B:\VIM_55\*.iso") -and !(Test-Path "B:\VIM_55\autorun.exe")){ 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." $vCenter55 = $true @@ -282,7 +371,8 @@ if (Test-Path "B:\VIM_55\*") { if (Test-Path "B:\VIM_51\*") { if ((Test-Path "B:\VIM_51\*.iso") -and !(Test-Path "B:\VIM_51\autorun.exe")) { 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." $vCenter51 = $true @@ -293,7 +383,8 @@ if (Test-Path "B:\VIM_51\*") { if (Test-Path "B:\VIM_50\*") { if ((Test-Path "B:\VIM_50\*.iso") -and !(Test-Path "B:\VIM_50\autorun.exe")) { 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." $vCenter50 = $true @@ -312,61 +403,66 @@ if (Test-Path "B:\VIM_41\*") { $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 "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." 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)) { - 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 } else { $vSphere60 = $true } 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 } else { $vSphere55 = $true } 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 } else { $vSphere51 = $true } 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 } else { $vSphere50 = $true } 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 } else { $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 "" -Write-BuildLog "Authorise and configure DHCP" -netsh dhcp server 192.168.199.4 set dnscredentials administrator lab.local $AdminPWD -netsh dhcp add server dc.lab.local 192.168.199.4 >> C:\DNS.log -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 -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 +$PCLIver = deployPowerCLI + +Write-BuildLog "Install, Authorise and configure DHCP" +If ((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -ge 62) { + $null = Add-WindowsFeature -IncludeManagementTools dhcp +} Write-BuildLog "Create DNS Records" dnscmd localhost /config /UpdateOptions 0x0 >> 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." dnscmd DC /RecordAdd lab.local _vlmcs._tcp SRV 0 10 1688 $KMSIP >> C:\DNS.log } - -Write-BuildLog "" +Write-BuildLog "Setup DHCP scope" +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." $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") { Write-BuildLog "SQL Server Install found, not installing" }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 - 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 $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 @@ -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 regedit -s B:\Automate\DC\SQLTCP.reg } else { + $vc67SQL = $false + $vc65SQL = $false $vc6SQL = $false $vc5SQL = $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 to 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)) { Write-BuildLog "Doing Windows Server 2008 specific build actions" 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." } else { 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)) { - 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." Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs Write-BuildLog "Disabling screen saver" set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0 - Write-BuildLog "Installing Administration tools." - Install-WindowsFeature –Name RSAT-DHCP,RSAT-DNS-Server,Net-Framework-Core + Write-BuildLog "Installing.Net Framework 3.5" + $null = Install-WindowsFeature Net-Framework-Core -source D:\Sources\sxs 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)) { 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 } } 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 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} @@ -521,7 +649,7 @@ If (((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]: New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https Write-BuildLog "Setup Certificate Authority & web enrollment." 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 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 @@ -543,6 +671,8 @@ Write-BuildLog "Cleanup and creating Desktop shortcuts." reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f wscript B:\Automate\DC\Shortcuts.vbs +browserAndFlash + if (Test-Path B:\Automate\automate.ini) { $timezone = ((Select-String -SimpleMatch "TZ=" -Path "B:\Automate\automate.ini").line).substring(3) 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 $vcinstall = ((Select-String -SimpleMatch "VCInstall=" -Path "B:\Automate\automate.ini").line).substring(10) 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 { 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 @@ -582,15 +722,15 @@ if (Test-Path -Path "B:\VMTools\setup*") { } } if (Test-Path -Path "B:\VMTools\setup*") { - Write-BuildLog "VMware Tools found." - $vmtools = $true -} - Write-BuildLog "" + Write-BuildLog "VMware Tools found." + $vmtools = $true + } } 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 "(Re)build vCenter next." 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" @@ -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") $mailmessage.Attachments.Add($attach) $SMTPClient.Send($mailmessage) + $mailmessage.dispose() + $SMTPClient.dispose() } Start-Process B:\VMTools\setup64.exe -ArgumentList '/s /v "/qn"' -verb RunAs -Wait Start-Sleep -Seconds 300 diff --git a/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi50.menu b/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi50.menu index eb0c81f..7bc3cc9 100644 --- a/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi50.menu +++ b/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi50.menu @@ -7,7 +7,7 @@ LABEL Main Menu label esx50 KERNEL /esxi50/mboot.c32 - APPEND -c /esxi50/boot.cfg + APPEND -c /esxi50/bootm.cfg MENU LABEL ESXi 5.0 Manual Install label esx1-5 diff --git a/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi51.menu b/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi51.menu index 156576b..3c666e7 100644 --- a/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi51.menu +++ b/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi51.menu @@ -7,7 +7,7 @@ LABEL Main Menu label esx51 KERNEL /esxi51/mboot.c32 - APPEND -c /esxi51/boot.cfg + APPEND -c /esxi51/bootm.cfg MENU LABEL ESXi 5.1 Manual Install label ESX1-5 diff --git a/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi55.menu b/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi55.menu index 9305063..87568bf 100644 --- a/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi55.menu +++ b/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi55.menu @@ -7,7 +7,7 @@ LABEL Main Menu label esx51 KERNEL /esxi55/mboot.c32 - APPEND -c /esxi55/boot.cfg + APPEND -c /esxi55/bootm.cfg MENU LABEL ESXi 5.5 Manual Install label ESX1-5 diff --git a/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi60.menu b/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi60.menu index 8f3cced..ba36829 100644 --- a/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi60.menu +++ b/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi60.menu @@ -7,7 +7,7 @@ LABEL Main Menu label esx51 KERNEL /esxi60/mboot.c32 - APPEND -c /esxi60/boot.cfg + APPEND -c /esxi60/bootm.cfg MENU LABEL ESXi 6.0 Manual Install label ESX1-5 diff --git a/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi65.menu b/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi65.menu new file mode 100644 index 0000000..ac30121 --- /dev/null +++ b/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi65.menu @@ -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 \ No newline at end of file diff --git a/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi67.menu b/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi67.menu new file mode 100644 index 0000000..49360a1 --- /dev/null +++ b/Build/Automate/DC/TFTP-Root/pxelinux.cfg/ESXi67.menu @@ -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 \ No newline at end of file diff --git a/Build/Automate/PSFunctions.ps1 b/Build/Automate/PSFunctions.ps1 index dc4d524..cbc1d1b 100644 --- a/Build/Automate/PSFunctions.ps1 +++ b/Build/Automate/PSFunctions.ps1 @@ -1,22 +1,86 @@ # Functions used in AutoLab PowerShell scripts # # -# Version 2.6 +# Version 3.0 # -# This Function from the PowerCLI Blog -# http://blogs.vmware.com/vipowershell/2009/08/how-to-list-datastores-that-are-on-shared-storage.html -# +function browserAndFlash { + 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 { param([string]$message) if (!(Test-Path C:\Buildlog.txt)) { New-Item -Path C:\Buildlog.txt -ItemType File } - Write-Host $message - $message | Out-File C:\BuildLog.txt -Encoding Default -append + $out = (get-date -f HH:mm:ss) + " " + $message + 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 { # Get all datastores. $datastores = Get-Datastore @@ -82,7 +146,7 @@ Function Check-File ($a, $b) { if (test-Path $a) { Write-Host ($b + " found.") -foregroundcolor "green" } else { - Write-Host ($b + " missing.") -foregroundcolor "red" + Write-Host ("**** " + $b + " missing.") -foregroundcolor "red" $Global:Pass = $False } } @@ -91,7 +155,7 @@ Function Check-OptionalFile ($a, $b) { if (test-Path $a) { Write-Host ($b + " found.") -foregroundcolor "green" } 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") { Write-Host ("Service " + $a + " running.") -foregroundcolor "green" } else { - Write-Host ("Service " + $a + " not running.") -foregroundcolor "red" + Write-Host ("**** Service " + $a + " not running.") -foregroundcolor "red" $Global:Pass = $False } } @@ -111,7 +175,7 @@ Function Check-DNSRecord ($a) { $FWDIP = [System.Net.Dns]::GetHostAddresses($a) $ErrorActionPreference = "continue" if ($FWDIP -eq "") { - Write-Host ("No DNS for " + $a ) -foregroundcolor "red" + Write-Host ("**** No DNS for " + $a ) -foregroundcolor "red" $Global:Pass = $False } else { Write-Host ("DNS OK for " + $a) -foregroundcolor "green" diff --git a/Build/Automate/PXEMenuConfig.ps1 b/Build/Automate/PXEMenuConfig.ps1 index 69bae25..e1d5204 100644 --- a/Build/Automate/PXEMenuConfig.ps1 +++ b/Build/Automate/PXEMenuConfig.ps1 @@ -22,9 +22,37 @@ param($version) . "C:\PSFunctions.ps1" 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 { 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 @" LABEL ESXi 60 @@ -33,12 +61,12 @@ LABEL ESXi 60 APPEND pxelinux.cfg/ESXi60.menu "@ } else { - Write-BuildLog "ESXi 5.5 already in PXE Menu" + Write-BuildLog "ESXi 6.0 already in PXE Menu" } } ESXi55 { 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 @" LABEL ESXi 5.5 @@ -52,7 +80,7 @@ LABEL ESXi 5.5 } ESXi51 { 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 @" LABEL ESXi 5.1 @@ -66,7 +94,7 @@ LABEL ESXi 5.1 } ESXi50 { 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 @" LABEL ESXi 5.0 @@ -78,7 +106,7 @@ LABEL ESXi 5.0 } 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 @" LABEL ESXi 4.1 @@ -102,7 +130,7 @@ label esxi2-4 } ESX41 { 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 @" label esx2-4 @@ -114,7 +142,7 @@ label esx2-4 } 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 @" LABEL vCloud @@ -126,7 +154,7 @@ LABEL vCloud } vCD51 { 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 @" label vCloud51 @@ -143,7 +171,7 @@ label vCloud51 } vCD15 { 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 @" label vCloud15 diff --git a/Build/Automate/SS/Build.cmd b/Build/Automate/SS/Build.cmd index 230ab3f..6f7b340 100644 --- a/Build/Automate/SS/Build.cmd +++ b/Build/Automate/SS/Build.cmd @@ -1,10 +1,12 @@ @echo off 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 -net use B: \\192.168.199.7\Build >> c:\buildlog.txt -type b:\automate\version.txt >> c:\buildlog.txt +echo * Connect to build share >> 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\NoSCRNSave.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 "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 +copy B:\automate\_Common\wasp.dll C:\windows\system32 echo * Activate Windows >> c:\buildlog.txt cscript //B "%windir%\system32\slmgr.vbs" /ato copy B:\Automate\PSFunctions.ps1 C:\ +copy B:\Automate\validate.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 >> C:\buildlog.txt diff --git a/Build/Automate/SS/Build.ps1 b/Build/Automate/SS/Build.ps1 index c86f8a1..4c12e7a 100644 --- a/Build/Automate/SS/Build.ps1 +++ b/Build/Automate/SS/Build.ps1 @@ -5,6 +5,13 @@ if (Test-Path C:\PSFunctions.ps1) { Read-Host "Press to 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") { 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) $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)) { Write-BuildLog "Disabling autorun of ServerManager at logon." 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" 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"' - } - 51 { + } 51 { Write-BuildLog "Install View 5.1 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=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" 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"' - } - 53 { + } 53 { Write-BuildLog "Install View 5.3 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=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" 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"' - } - 70 { + } 70 { Write-BuildLog "Install View 7.0 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"' -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" -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 + +browserAndFlash + 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 Write-BuildLog "Install VMware Tools" b:\VMTools\Setup64.exe /s /v "/qn" 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" @@ -95,5 +114,7 @@ if (([bool]($emailto -as [Net.Mail.MailAddress])) -and ($SmtpServer -ne "none")) $attach = new-object Net.Mail.Attachment("C:\buildlog.txt") $mailmessage.Attachments.Add($attach) $SMTPClient.Send($mailmessage) + $mailmessage.dispose() + $SMTPClient.dispose() } Read-Host "Rebooting after VMTools Install" diff --git a/Build/Automate/Shared/ExecuPol.reg b/Build/Automate/Shared/ExecuPol.reg deleted file mode 100644 index 93a125d..0000000 Binary files a/Build/Automate/Shared/ExecuPol.reg and /dev/null differ diff --git a/Build/Automate/Shared/NoSCRNSave.reg b/Build/Automate/Shared/NoSCRNSave.reg deleted file mode 100644 index b753763..0000000 Binary files a/Build/Automate/Shared/NoSCRNSave.reg and /dev/null differ diff --git a/Build/Automate/VC/Build.cmd b/Build/Automate/VC/Build.cmd index d7cc6f1..09ad38d 100644 --- a/Build/Automate/VC/Build.cmd +++ b/Build/Automate/VC/Build.cmd @@ -1,12 +1,12 @@ @echo off 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 >> c:\buildlog.txt -net use B: \\192.168.199.7\Build >> c:\buildlog.txt -md c:\temp -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\NoSCRNSave.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\VC\Build.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 cscript //B "%windir%\system32\slmgr.vbs" /ato echo * Starting PowerShell script for Build echo * Starting PowerShell script for Build >> C:\buildlog.txt powershell c:\Build.ps1 -if exist C:\Build.ps1 del c:\Build.ps1 -if exist C:\Build.cmd del c:\Build.cmd \ No newline at end of file diff --git a/Build/Automate/VC/Build.ps1 b/Build/Automate/VC/Build.ps1 index f4c15e1..33620c4 100644 --- a/Build/Automate/VC/Build.ps1 +++ b/Build/Automate/VC/Build.ps1 @@ -5,6 +5,14 @@ if (Test-Path C:\PSFunctions.ps1) { Read-Host "Press to 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 if (Test-Path "B:\Automate\automate.ini") { @@ -99,97 +107,129 @@ if (Test-Path "B:\Automate\automate.ini") { } else { 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) { Write-BuildLog "Disabling autorun of ServerManager at logon." Start-Process schtasks -ArgumentList ' /Change /TN "\Microsoft\Windows\Server Manager\ServerManager" /DISABLE' -Wait -Verb RunAs Write-BuildLog "Disabling screen saver" 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." -try { - Start-Process msiexec -ArgumentList '/qb /i B:\Automate\_Common\7z920-x64.msi' -Wait -} -catch { - Write-BuildLog "7-zip installation failed." -} +Start-Process msiexec -ArgumentList '/qb /i B:\Automate\_Common\7z1805-x64.msi' -Wait +do { + start-sleep 10 +} until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null) + Write-BuildLog "Installing PuTTy." $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 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 -#$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 +browserAndFlash Write-BuildLog "Change default local administrator password" net user administrator $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 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) { + 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 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 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 { Write-BuildLog "Starting vCenter 6.0 automation." if (Test-Path "b:\VIM_60\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") { @@ -204,7 +244,9 @@ switch ($vcinstall) { 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 - start-sleep -s 10 + do { + start-sleep 10 + } until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null) } } else { 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" 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" If (!(Test-Path("c:\temp\VMware-ClientIntegrationPlugin-6.0.0.exe"))) { B: @@ -226,28 +271,19 @@ switch ($vcinstall) { $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." 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 ((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." - 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." - 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." - 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 + If (($DeployVUM) -and ($vcinstall -eq "60")) { + do { + start-sleep 10 + } until ((get-process "msiexec" -ea SilentlyContinue) -eq $Null) + 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 { - 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 { @@ -295,23 +331,6 @@ switch ($vcinstall) { 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:\ 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 { Write-BuildLog "Starting vCenter 5.1 automation." @@ -358,13 +377,6 @@ switch ($vcinstall) { 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:\ 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 { Write-BuildLog "Starting vCenter 5 automation." @@ -388,11 +400,7 @@ switch ($vcinstall) { Write-BuildLog "Installing vCenter and vSphere client." copy b:\automate\vc\vc50.cmd c:\ 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 { Write-BuildLog "Starting vCenter 4.1 automation." if (Test-Path "b:\VIM_41\redist\SQLEXPR\x64\SQLEXPR.EXE") { @@ -408,11 +416,7 @@ switch ($vcinstall) { } copy b:\automate\vc\vc41.cmd c:\ 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 { 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." @@ -460,6 +464,7 @@ switch ($vcinstall) { } None {} } + If ($viewinstall -ne "None") { $Files = get-childitem "b:\view$viewinstall" for ($i=0; $i -lt $files.Count; $i++) { @@ -467,33 +472,30 @@ If ($viewinstall -ne "None") { } } 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") { Write-BuildLog "Setup install VMware View 7.0 Composer, reboot required before install" 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 { if (Test-Path "B:\View60\VMware-viewcomposer-*.exe") { Write-BuildLog "Setup install VMware View 6.0 Composer, reboot required before install" 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 { if (Test-Path "B:\View53\VMware-viewcomposer-5.3*.exe") { Write-BuildLog "Setup install VMware View 5.3 Composer, reboot required before install" 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 { if (Test-Path "B:\View52\VMware-viewcomposer-5.2*.exe") { Write-BuildLog "Setup install VMware View 5.2 Composer, reboot required before install" 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 { @@ -518,54 +520,16 @@ if (Test-Path "b:\VMware-vSphere-CLI.exe") { 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)) { Write-BuildLog "Creating fully automated Windows 2003 install ISO." $null = New-Item -Path c:\temp\Win2K3 -ItemType Directory -Force cd c:\temp\Win2K3 . "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)) { 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 - 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)) { 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)){ 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] 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 @@ -612,6 +576,11 @@ if ($buildviewvm -and (Test-Path B:\WinXP.iso)) { 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." regedit -s b:\Automate\vc\vSphereClient.reg 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 wscript c:\Shortcuts.vbs copy b:\Automate\*.ps1 c:\ - -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}" -$UserKey = "HKLM:\SOFTWARE\Microsoft\Active Setup\Installed Components\{A509B1A8-37EF-4b3f-8CFC-4F3A74704073}" -Set-ItemProperty -Path $AdminKey -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 +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" + $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}" + Set-ItemProperty -Path $AdminKey -Name "IsInstalled" -Value 0 + Set-ItemProperty -Path $UserKey -Name "IsInstalled" -Value 0 } Write-BuildLog "Installing VMware tools, build complete after reboot." if (Test-Path B:\VMTools\setup64.exe) { #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 $SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25) $mailmessage.from = "AutoLab" @@ -652,6 +615,8 @@ if (Test-Path B:\VMTools\setup64.exe) { $attach = new-object Net.Mail.Attachment("C:\buildlog.txt") $mailmessage.Attachments.Add($attach) $SMTPClient.Send($mailmessage) + $mailmessage.dispose() + $SMTPClient.dispose() } Start-Process B:\VMTools\setup64.exe -ArgumentList '/s /v "/qn"' -verb RunAs -Wait } diff --git a/Build/Automate/VC/Phase2.ps1 b/Build/Automate/VC/Phase2.ps1 new file mode 100644 index 0000000..2aa5e2b --- /dev/null +++ b/Build/Automate/VC/Phase2.ps1 @@ -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" + $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() +} \ No newline at end of file diff --git a/Build/Automate/VC/Shortcuts.vbs b/Build/Automate/VC/Shortcuts.vbs index b581225..2f7ec1a 100644 --- a/Build/Automate/VC/Shortcuts.vbs +++ b/Build/Automate/VC/Shortcuts.vbs @@ -1,14 +1,4 @@ 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") oShortCutLink.TargetPath = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe" oShortCutLink.Arguments = " c:\ScriptMenu.ps1" diff --git a/Build/Automate/VC/vCentre60.json b/Build/Automate/VC/vCentre60.json index 7031a26..06b30f9 100644 --- a/Build/Automate/VC/vCentre60.json +++ b/Build/Automate/VC/vCentre60.json @@ -70,5 +70,32 @@ "vmdir.password" : "VMware1!", "vmdir.replication-partner-hostname" : null, "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 + } } diff --git a/Build/Automate/Validate.ps1 b/Build/Automate/Validate.ps1 index c3b797e..649ba13 100644 --- a/Build/Automate/Validate.ps1 +++ b/Build/Automate/Validate.ps1 @@ -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 +$Auto = $False +foreach ($arg in $args) { + If ($arg -like "auto") { $Auto = $True} +} if (Test-Path C:\PSFunctions.ps1) { . "C:\PSFunctions.ps1" } else { Write-Host "PSFunctions.ps1 not found. Please copy all PowerShell files from B:\Automate to C:\ and rerun AddHosts.ps1" - Read-Host "Press to exit" + If (!($Auto)) {Read-Host "Press to exit" } exit } @@ -23,13 +27,19 @@ if (Test-Administrator) { # make script window as tall as possible $a = (Get-Host).UI.RawUI +$a.WindowTitle = "AutoLab Validation" $b = $a.WindowSize $b.Height = $a.MaxWindowSize.Height - 1 $a.WindowSize = $b Import-Module C:\windows\system32\WASP.dll -Select-Window -Title "Administrator:" | set-windowposition -left 3 -top 3 -If (!(Test-Path "B:\*")) { - net use B: \\192.168.199.7\Build +Select-Window -Title "AutoLab Validation" | set-windowposition -left 75 -top 3 +If (!(Test-Path "B:\Automate\automate.ini" -ErrorAction SilentlyContinue)) { + 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 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 if ($CompName -eq "DC") { Write-Host "Validating required Build share components." -foregroundcolor "cyan" - $AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9) - If ($AdminPWD -eq "VMware1!") { - Write-Host "Default admin password set, this isn't safe." -foregroundcolor "Red" - $NewPWD = Read-Host "Enter a new admin password" - If ($NewPWD -ne "") { - Write-Host "Setting new password" -foregroundcolor "Green" - $OldAdminPWD = $AdminPWD - $AdminPWD = $NewPWD - $FileContent = get-content B:\Automate\automate.ini - Set-Content B:\Automate\automate.ini "" - Foreach ($Line in $FileContent){ - If ($Line.StartsWith("Adminpwd")) { $Line = "Adminpwd=$NewPWD"} - Add-Content B:\Automate\automate.ini $Line + if ($BDrive) { + $AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9) + If (($AdminPWD -eq "VMware1!") -and (!($Auto))) { + Write-Host "Default admin password set, this isn't safe." -foregroundcolor "Red" + $NewPWD = Read-Host "Enter a new admin password" + If ($NewPWD -ne "") { + Write-Host "Setting new password" -foregroundcolor "Green" + $OldAdminPWD = $AdminPWD + $AdminPWD = $NewPWD + $FileContent = get-content B:\Automate\automate.ini + Set-Content B:\Automate\automate.ini "" + Foreach ($Line in $FileContent){ + 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*") { @@ -98,82 +110,104 @@ if ($CompName -eq "DC") { 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\*"} - $vSpherePaths.GetEnumerator() | % {if (!(Test-Path $_.Value)) {New-Variable -Name $_.Name -Value $false -force} else {New-Variable -Name $_.Name -Value $true -force}} - if ($vCenter41 -and ($ESXi41 -or $ESX41)) { - Write-Host "vCenter 4.1 & ESXi 4.1 found." -foregroundcolor "green" - $vSphere41 = $true - } elseif ($vCenter41 -or ($ESXi41 -or $ESX41)) { - 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" - $vSphere41 = $false - } else { - 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 ($BDrive) { + $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\*"} + $vSpherePaths.GetEnumerator() | % {if (!(Test-Path $_.Value)) {New-Variable -Name $_.Name -Value $false -force} else {New-Variable -Name $_.Name -Value $true -force}} + if ($vCenter41 -and ($ESXi41 -or $ESX41)) { + Write-Host "vCenter 4.1 & ESXi 4.1 found." -foregroundcolor "green" + $vSphere41 = $true + } elseif ($vCenter41 -or ($ESXi41 -or $ESX41)) { + 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" + $vSphere41 = $false + } else { + 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 ($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" 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" @@ -185,61 +219,71 @@ if ($CompName -eq "DC") { 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.cfg" "PXE boot configuration file" - if ($ESX41 -and (Test-Path "C:\TFTP-Root\ESX41\*")) { - Write-Host "ESX 4.1 TFTP files found." -foregroundcolor "green" - } elseif ($ESX41 -and !(Test-Path "C:\TFTP-Root\ESX41\*")) { - 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" - } elseif ($ESXi41 -and !(Test-Path "C:\TFTP-Root\ESXi41\*")) { - 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" - } elseif ($ESXi50 -and !(Test-Path "C:\TFTP-Root\ESXi50\*")) { - 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" - } elseif ($ESXi51 -and !(Test-Path "C:\TFTP-Root\ESXi51\*")) { - 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" - } elseif ($ESXi55 -and !(Test-Path "C:\TFTP-Root\ESXi55\*")) { - 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" - } elseif ($ESXi60 -and !(Test-Path "C:\TFTP-Root\ESXi60\*")) { - Write-Host "ESXi 6.0 TFTP files not found on DC, but they exist on Build share." -foregroundcolor "red" - $Global:Pass = $false - } + if ($BDrive) { + if ($ESX41 -and (Test-Path "C:\TFTP-Root\ESX41\*")) { + Write-Host "ESX 4.1 TFTP files found." -foregroundcolor "green" + } elseif ($ESX41 -and !(Test-Path "C:\TFTP-Root\ESX41\*")) { + 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" + } elseif ($ESXi41 -and !(Test-Path "C:\TFTP-Root\ESXi41\*")) { + 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" + } elseif ($ESXi50 -and !(Test-Path "C:\TFTP-Root\ESXi50\*")) { + 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" + } elseif ($ESXi51 -and !(Test-Path "C:\TFTP-Root\ESXi51\*")) { + 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" + } elseif ($ESXi55 -and !(Test-Path "C:\TFTP-Root\ESXi55\*")) { + 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" + } elseif ($ESXi60 -and !(Test-Path "C:\TFTP-Root\ESXi60\*")) { + 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) - If ($vcinstall -eq "50") {$vcinstall = "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" - $Global:Pass = $false + $vcinstall = ((Select-String -SimpleMatch "VCInstall=" -Path "B:\Automate\automate.ini").line).substring(10) + If ($vcinstall -eq "50") {$vcinstall = "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" + $Global:Pass = $false + } + 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" + $Global:Pass = $false + } + 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" + $Global:Pass = $false + } + 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" + $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 + } } - 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" - $Global:Pass = $false - } - 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" - $Global:Pass = $false - } - 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" - $Global:Pass = $false - } Write-Host "Check Domain" -foregroundcolor "cyan" $domain = [System.DirectoryServices.ActiveDirectory.Domain]::GetCurrentDomain() if ($domain.Name -eq "lab.local") { @@ -256,7 +300,7 @@ if ($CompName -eq "DC") { Check-ServiceRunning "Tftpd32_svc" Check-ServiceRunning "SQL Server (SQLEXPRESS)" 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" Check-DNSRecord ("dc.lab.local") Check-DNSRecord ("vc.lab.local") @@ -277,13 +321,13 @@ if ($CompName -eq "DC") { if ($CompName -eq "VC") { $HaveXP = test-Path("\\192.168.199.7\Build\WinXP.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" If (Test-path "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" $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 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"} Check-ServiceRunning "VMware VirtualCenter Server" Check-ServiceRunning "VMware vSphere Web Client" Check-ServiceRunning "VMware Directory 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 { Write-Host "vCenter is not installed" -foregroundcolor "Yellow" } @@ -338,7 +394,7 @@ if ($CompName -eq "DC2") { Check-ServiceRunning "Netlogon" Check-ServiceRunning "SQL Server (SQLEXPRESS)" 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" Check-DNSRecord ("dc.lab.local") Check-DNSRecord ("vc.lab.local") @@ -358,7 +414,7 @@ if ($CompName -eq "DC2") { } 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") { Write-Host "Check Services" -foregroundcolor "cyan" Check-ServiceRunning "VMware VirtualCenter Management Webservices" @@ -368,7 +424,10 @@ if ($CompName -eq "VC2") { 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" if ($Global:Pass -eq $false ) { Write-Host ("*****************************************") -foregroundcolor "red" @@ -387,4 +446,4 @@ if ($Global:Pass -eq $false ) { Write-Host ("*") -foregroundcolor "green" Write-Host ("**************************************") -foregroundcolor "green" } -Read-host " Press to exit" \ No newline at end of file +If (!($Auto)) {Read-host " Press to exit"} \ No newline at end of file diff --git a/Build/Automate/Version.txt b/Build/Automate/Version.txt index 2322ecb..abc98bf 100644 --- a/Build/Automate/Version.txt +++ b/Build/Automate/Version.txt @@ -1,7 +1,7 @@ ** -* Autolab V2.6 +* Autolab V3.0 ** -* Released April 2015 +* Released June 2018 ** * New versions and updates at www.labguides.com ** diff --git a/Build/Automate/_Common/Firefox Setup 59.0.3.exe b/Build/Automate/_Common/Firefox Setup 59.0.3.exe new file mode 100644 index 0000000..fd4f9eb Binary files /dev/null and b/Build/Automate/_Common/Firefox Setup 59.0.3.exe differ diff --git a/Build/Automate/_Common/profile.ps1 b/Build/Automate/_Common/profile.ps1 new file mode 100644 index 0000000..c4d45b5 --- /dev/null +++ b/Build/Automate/_Common/profile.ps1 @@ -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" +} + diff --git a/Build/Automate/automate.ini b/Build/Automate/automate.ini index ccb303a..ff4b14c 100644 --- a/Build/Automate/automate.ini +++ b/Build/Automate/automate.ini @@ -2,7 +2,7 @@ TZ=New Zealand Standard Time VCInstall=60 -VCInstallOptions=4,5,51,55,60,None,Base +VCInstallOptions=4,5,51,55,60,65,67,None,Base AutoAddHosts=false DeployVUM=true Adminpwd=VMware1! @@ -12,7 +12,7 @@ BuildVM=true ProductKey=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX ViewInstall=None -ViewInstallOptions=50,51,52,53,60,None +ViewInstallOptions=50,51,52,53,60,70,None BuildViewVM=true ViewVMProductKey=XXXXX-XXXXX-XXXXX-XXXXX-XXXXX diff --git a/Build/ChangeLog.txt b/Build/ChangeLog.txt index 6711bb2..c32aefb 100644 --- a/Build/ChangeLog.txt +++ b/Build/ChangeLog.txt @@ -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 +- 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 - Support for vSphere 6.0 diff --git a/Build/gparted/ReadMe.txt b/Build/gparted/ReadMe.txt index 430f1d2..1cc2875 100644 --- a/Build/gparted/ReadMe.txt +++ b/Build/gparted/ReadMe.txt @@ -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 initrd.img diff --git a/SRC/VC/VC.flp b/SRC/CS1/CS1-Config.iso similarity index 76% rename from SRC/VC/VC.flp rename to SRC/CS1/CS1-Config.iso index 9a2fb49..7cf82bc 100644 Binary files a/SRC/VC/VC.flp and b/SRC/CS1/CS1-Config.iso differ diff --git a/SRC/CS1/autoUnattend.xml b/SRC/CS1/autoUnattend.xml index a9ac903..0f65269 100644 --- a/SRC/CS1/autoUnattend.xml +++ b/SRC/CS1/autoUnattend.xml @@ -18,7 +18,7 @@ /IMAGE/INDEX - 1 + 2 @@ -134,9 +134,21 @@ a:\Build.cmd - Build + Phase One Installer from A Drive 1 true + + + D:\Build.cmd + Phase One Installer from D Drive + 2 + true + + + E:\Build.cmd + Phase One Installer from E Drive + 3 + true diff --git a/SRC/CS1/build.cmd b/SRC/CS1/build.cmd index 6d14ab5..c7f7b45 100644 --- a/SRC/CS1/build.cmd +++ b/SRC/CS1/build.cmd @@ -6,27 +6,22 @@ ver | find "6.2" > nul if %ERRORLEVEL% == 0 goto ver_2K12 ver | find "6.3" > nul if %ERRORLEVEL% == 0 goto ver_2K12 +ver | find "10.0" > nul +if %ERRORLEVEL% == 0 goto ver_2K16 goto RunBuild :ver_2K8 goto RunBuild :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="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="Ethernet0" static address=192.168.199.4 primary Dism /online /enable-feature /featurename:NetFx3ServerFeatures Dism /online /enable-feature /featurename:NetFx3 /source:D:\Sources\sxs 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 :RunBuild copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\ diff --git a/Build/Automate/BootFloppies/VC2.flp b/SRC/CS2/CS2-Config.iso similarity index 76% rename from Build/Automate/BootFloppies/VC2.flp rename to SRC/CS2/CS2-Config.iso index f8317f4..94096b7 100644 Binary files a/Build/Automate/BootFloppies/VC2.flp and b/SRC/CS2/CS2-Config.iso differ diff --git a/SRC/CS2/autoUnattend.xml b/SRC/CS2/autoUnattend.xml index e896c19..e3e0c90 100644 --- a/SRC/CS2/autoUnattend.xml +++ b/SRC/CS2/autoUnattend.xml @@ -18,7 +18,7 @@ /IMAGE/INDEX - 1 + 2 @@ -130,10 +130,22 @@ - a:\Build.cmd - Build + A:\Build.cmd + Phase One Installer from A Drive 1 true + + + D:\Build.cmd + Phase One Installer from D Drive + 2 + true + + + E:\Build.cmd + Phase One Installer from E Drive + 3 + true diff --git a/SRC/CS2/build.cmd b/SRC/CS2/build.cmd index 9cda843..3a166be 100644 --- a/SRC/CS2/build.cmd +++ b/SRC/CS2/build.cmd @@ -6,27 +6,21 @@ ver | find "6.2" > nul if %ERRORLEVEL% == 0 goto ver_2K12 ver | find "6.3" > nul if %ERRORLEVEL% == 0 goto ver_2K12 +ver | find "10.0" > nul +if %ERRORLEVEL% == 0 goto ver_2K16 goto RunBuild :ver_2K8 goto RunBuild :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="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="Ethernet0" static address=192.168.199.4 primary Dism /online /enable-feature /featurename:NetFx3ServerFeatures Dism /online /enable-feature /featurename:NetFx3 /source:D:\Sources\sxs 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 :RunBuild copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\ diff --git a/SRC/DC/Build.cmd b/SRC/DC/Build.cmd index a9fbedb..85dc072 100644 --- a/SRC/DC/Build.cmd +++ b/SRC/DC/Build.cmd @@ -5,49 +5,65 @@ ver | find "6.2" > nul if %ERRORLEVEL% == 0 goto ver_2K12 ver | find "6.3" > nul if %ERRORLEVEL% == 0 goto ver_2K12 +ver | find "10." > nul +if %ERRORLEVEL% == 0 goto ver_2K16 Exit :ver_2K8 echo ** -echo * Building on Windows 2008 R2 -echo * Building on Windows 2008 R2 >> c:\buildlog.txt +echo * Building on Windows 2008 core +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 >> 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 +echo * Promote to DC +echo * Promote to DC >> 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 +exit :ver_2K12 echo ** echo * Building on Windows 2012 R2 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 >> 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 -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 +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 >> 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 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 +#echo * Promote to DC +#echo * Promote to DC >> c:\buildlog.txt +#copy \\192.168.199.7\Build\Automate\DC\dcpromo.ps1 c:\ +#pause +#powershell c:\dcpromo.ps1 +#pause Installing AD, will reboot after Exit \ No newline at end of file diff --git a/SRC/CS1/CS1.flp b/SRC/DC/DC-Config.iso similarity index 76% rename from SRC/CS1/CS1.flp rename to SRC/DC/DC-Config.iso index 1a89be1..658ac11 100644 Binary files a/SRC/CS1/CS1.flp and b/SRC/DC/DC-Config.iso differ diff --git a/SRC/DC/Ravello/Build.cmd b/SRC/DC/Ravello/Build.cmd deleted file mode 100644 index a9fbedb..0000000 --- a/SRC/DC/Ravello/Build.cmd +++ /dev/null @@ -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 \ No newline at end of file diff --git a/SRC/DC/Ravello/DC-Config.iso b/SRC/DC/Ravello/DC-Config.iso deleted file mode 100644 index 01fe5e6..0000000 Binary files a/SRC/DC/Ravello/DC-Config.iso and /dev/null differ diff --git a/SRC/DC/Ravello/DC-Config.iso.uibak b/SRC/DC/Ravello/DC-Config.iso.uibak deleted file mode 100644 index 4278f8d..0000000 Binary files a/SRC/DC/Ravello/DC-Config.iso.uibak and /dev/null differ diff --git a/SRC/DC/autoUnattend.xml b/SRC/DC/autoUnattend.xml index 69cd7d2..8312cd6 100644 --- a/SRC/DC/autoUnattend.xml +++ b/SRC/DC/autoUnattend.xml @@ -18,7 +18,7 @@ /IMAGE/INDEX - 1 + 2 @@ -107,13 +107,13 @@ 1 true - + D:\Build.cmd Phase One Installer from D Drive 2 true - + E:\Build.cmd Phase One Installer from E Drive 3 diff --git a/SRC/DC2.flp b/SRC/DC2.flp deleted file mode 100644 index 9741d90..0000000 Binary files a/SRC/DC2.flp and /dev/null differ diff --git a/SRC/MakeVMNet3.reg b/SRC/MakeVMNet3.reg deleted file mode 100644 index 044f776..0000000 --- a/SRC/MakeVMNet3.reg +++ /dev/null @@ -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 diff --git a/SRC/Nested10/Build.cmd b/SRC/Nested10/Build.cmd new file mode 100644 index 0000000..e096b3a --- /dev/null +++ b/SRC/Nested10/Build.cmd @@ -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 \ No newline at end of file diff --git a/SRC/Nested10/Nested10.flp b/SRC/Nested10/Nested10.flp new file mode 100644 index 0000000..07ce9d1 Binary files /dev/null and b/SRC/Nested10/Nested10.flp differ diff --git a/SRC/DC/Ravello/autoUnattend.xml b/SRC/Nested10/autoUnattend.xml similarity index 68% rename from SRC/DC/Ravello/autoUnattend.xml rename to SRC/Nested10/autoUnattend.xml index f963525..e720c2d 100644 --- a/SRC/DC/Ravello/autoUnattend.xml +++ b/SRC/Nested10/autoUnattend.xml @@ -18,7 +18,7 @@ /IMAGE/INDEX - 2 + 1 @@ -45,39 +45,13 @@ - dc - - - - - - false - 10 - false - - - 192.168.199.4/24 - - Local Area Connection - - - 0 - 10 - 192.168.199.2 - 0.0.0.0/0 - - - - + Template10 false false false - - true - true @@ -88,6 +62,16 @@ false false + + + + + true + + 1 + + + @@ -102,48 +86,31 @@ - A:\Build.cmd - Phase One Installer from A Drive + a:\Build.cmd + Phase One Installer 1 true - - - D:\Build.cmd - Phase One Installer from D Drive - 2 - true - - - E:\Build.cmd - Phase One Installer from E Drive - 3 - true true true Work + true + true + true + true + true + false + 1 VgBNAHcAYQByAGUAMQAhAEEAZABtAGkAbgBpAHMAdAByAGEAdABvAHIAUABhAHMAcwB3AG8AcgBkAA== false</PlainText> </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> </component> </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> diff --git a/Build/Automate/BootFloppies/DC2.flp b/SRC/Nested2008/Nested2008.flp similarity index 99% rename from Build/Automate/BootFloppies/DC2.flp rename to SRC/Nested2008/Nested2008.flp index 837f650..ba19a04 100644 Binary files a/Build/Automate/BootFloppies/DC2.flp and b/SRC/Nested2008/Nested2008.flp differ diff --git a/SRC/Nested2106/Nested2016.flp b/SRC/Nested2106/Nested2016.flp new file mode 100644 index 0000000..95100e3 Binary files /dev/null and b/SRC/Nested2106/Nested2016.flp differ diff --git a/SRC/Nested7/Build.cmd b/SRC/Nested7/Build.cmd new file mode 100644 index 0000000..a79658e --- /dev/null +++ b/SRC/Nested7/Build.cmd @@ -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 \ No newline at end of file diff --git a/SRC/Nested7/Nested7.flp b/SRC/Nested7/Nested7.flp new file mode 100644 index 0000000..1654b4c Binary files /dev/null and b/SRC/Nested7/Nested7.flp differ diff --git a/SRC/Nested7/autoUnattend.xml b/SRC/Nested7/autoUnattend.xml new file mode 100644 index 0000000..d90f2c5 --- /dev/null +++ b/SRC/Nested7/autoUnattend.xml @@ -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> diff --git a/SRC/Nested8/Build.cmd b/SRC/Nested8/Build.cmd new file mode 100644 index 0000000..87276f3 --- /dev/null +++ b/SRC/Nested8/Build.cmd @@ -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 \ No newline at end of file diff --git a/SRC/Nested8/Nested8.flp b/SRC/Nested8/Nested8.flp new file mode 100644 index 0000000..8ed4d26 Binary files /dev/null and b/SRC/Nested8/Nested8.flp differ diff --git a/SRC/VC/Ravello/autoUnattend.xml b/SRC/Nested8/autoUnattend.xml similarity index 57% rename from SRC/VC/Ravello/autoUnattend.xml rename to SRC/Nested8/autoUnattend.xml index 2da2d63..d93447f 100644 --- a/SRC/VC/Ravello/autoUnattend.xml +++ b/SRC/Nested8/autoUnattend.xml @@ -18,7 +18,7 @@ <InstallFrom> <MetaData wcm:action="add"> <Key>/IMAGE/INDEX</Key> - <Value>2</Value> + <Value>1</Value> </MetaData> </InstallFrom> </OSImage> @@ -45,79 +45,32 @@ </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>vc</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> + <ComputerName>Template8</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-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"> - <IEHardenAdmin>false</IEHardenAdmin> <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"> @@ -128,9 +81,17 @@ <PlainText>false</PlainText> </Password> <Enabled>true</Enabled> - <LogonCount>99</LogonCount> - <Username>vc\Administrator</Username> + <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> @@ -142,27 +103,10 @@ <PlainText>false</PlainText> </AdministratorPassword> </UserAccounts> - <FirstLogonCommands> - <SynchronousCommand wcm:action="add"> - <CommandLine>A:\Build.cmd</CommandLine> - <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> + <BluetoothTaskbarIconEnabled>false</BluetoothTaskbarIconEnabled> + <DisableAutoDaylightTimeSet>false</DisableAutoDaylightTimeSet> + <ShowWindowsLive>false</ShowWindowsLive> </component> </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> diff --git a/SRC/CS2/CS2.flp b/SRC/SS/SS-Config.iso similarity index 76% rename from SRC/CS2/CS2.flp rename to SRC/SS/SS-Config.iso index c2b17eb..bccd507 100644 Binary files a/SRC/CS2/CS2.flp and b/SRC/SS/SS-Config.iso differ diff --git a/SRC/SS/SS.flp b/SRC/SS/SS.flp deleted file mode 100644 index 74fd88c..0000000 Binary files a/SRC/SS/SS.flp and /dev/null differ diff --git a/SRC/SS/autoUnattend.xml b/SRC/SS/autoUnattend.xml index 8ce66ce..5f37268 100644 --- a/SRC/SS/autoUnattend.xml +++ b/SRC/SS/autoUnattend.xml @@ -18,7 +18,7 @@ <InstallFrom> <MetaData wcm:action="add"> <Key>/IMAGE/INDEX</Key> - <Value>1</Value> + <Value>2</Value> </MetaData> </InstallFrom> </OSImage> @@ -130,10 +130,22 @@ </UserAccounts> <FirstLogonCommands> <SynchronousCommand wcm:action="add"> - <CommandLine>a:\Build.cmd</CommandLine> - <Description>Build</Description> + <CommandLine>A:\Build.cmd</CommandLine> + <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> diff --git a/SRC/SS/build.cmd b/SRC/SS/build.cmd index 7ca5d70..2662cc0 100644 --- a/SRC/SS/build.cmd +++ b/SRC/SS/build.cmd @@ -6,27 +6,21 @@ ver | find "6.2" > nul if %ERRORLEVEL% == 0 goto ver_2K12 ver | find "6.3" > nul if %ERRORLEVEL% == 0 goto ver_2K12 +ver | find "10.0" > nul +if %ERRORLEVEL% == 0 goto ver_2K16 goto RunBuild :ver_2K8 goto RunBuild :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="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="Ethernet0" static address=192.168.199.4 primary Dism /online /enable-feature /featurename:NetFx3ServerFeatures Dism /online /enable-feature /featurename:NetFx3 /source:D:\Sources\sxs 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 :RunBuild copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\ diff --git a/SRC/VC.flp b/SRC/VC.flp deleted file mode 100644 index 6a6174b..0000000 Binary files a/SRC/VC.flp and /dev/null differ diff --git a/SRC/VC/Build.cmd b/SRC/VC/Build.cmd index e418767..cac7b05 100644 --- a/SRC/VC/Build.cmd +++ b/SRC/VC/Build.cmd @@ -1,4 +1,6 @@ @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 ver | find "6.1" > nul if %ERRORLEVEL% == 0 goto ver_2K8 @@ -6,17 +8,26 @@ ver | find "6.2" > nul if %ERRORLEVEL% == 0 goto ver_2K12 ver | find "6.3" > nul if %ERRORLEVEL% == 0 goto ver_2K12 +ver | find "10.0" > nul +if %ERRORLEVEL% == 0 goto ver_2K16 goto RunBuild :ver_2K8 -goto RunBuild -:ver_2K12 echo ** -echo * Building on Windows 2012 -echo * Building on Windows 2012 >> c:\buildlog.txt +echo * Building on Windows 2008 core +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.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 "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 @@ -26,23 +37,34 @@ 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 +shutdown -r -t 1 +exit +:ver_2K12 +echo ** +echo * Building on Windows 2012 +echo * Building on Windows 2012 >> c:\buildlog.txt +goto StartBuild +:ver_2K16 +echo ** +echo * Building on Windows 2012 +echo * Building on Windows 2012 >> c:\buildlog.txt +goto StartBuild +:StartBuild +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 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 copy \\192.168.199.7\Build\automate\%computername%\Build.cmd c:\ c:\build.cmd diff --git a/SRC/VC/Ravello/Build.cmd b/SRC/VC/Ravello/Build.cmd deleted file mode 100644 index e418767..0000000 --- a/SRC/VC/Ravello/Build.cmd +++ /dev/null @@ -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 \ No newline at end of file diff --git a/SRC/VC/Ravello/VC-Config.iso b/SRC/VC/Ravello/VC-Config.iso deleted file mode 100644 index 49eff94..0000000 Binary files a/SRC/VC/Ravello/VC-Config.iso and /dev/null differ diff --git a/SRC/VC/Ravello/VC-Config.iso.uibak b/SRC/VC/Ravello/VC-Config.iso.uibak deleted file mode 100644 index 906baa8..0000000 Binary files a/SRC/VC/Ravello/VC-Config.iso.uibak and /dev/null differ diff --git a/Build/Automate/BootFloppies/VC.flp b/SRC/VC/VC-Config.iso similarity index 76% rename from Build/Automate/BootFloppies/VC.flp rename to SRC/VC/VC-Config.iso index 55b8579..825dfed 100644 Binary files a/Build/Automate/BootFloppies/VC.flp and b/SRC/VC/VC-Config.iso differ diff --git a/SRC/VC/autoUnattend.xml b/SRC/VC/autoUnattend.xml index 0fb7e6c..2da2d63 100644 --- a/SRC/VC/autoUnattend.xml +++ b/SRC/VC/autoUnattend.xml @@ -18,7 +18,7 @@ <InstallFrom> <MetaData wcm:action="add"> <Key>/IMAGE/INDEX</Key> - <Value>1</Value> + <Value>2</Value> </MetaData> </InstallFrom> </OSImage> diff --git a/SRC/VC2.flp b/SRC/VC2.flp deleted file mode 100644 index 68fb552..0000000 Binary files a/SRC/VC2.flp and /dev/null differ diff --git a/SRC/buildpop b/SRC/buildpop deleted file mode 100644 index c9c10ac..0000000 --- a/SRC/buildpop +++ /dev/null @@ -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" -