Initial commit

AutoLab build 2.6.
Previously hosted on Google Code
pull/45/head
DemitasseNZ 2015-05-01 12:38:03 +12:00
parent 53666f4a8a
commit 66af6e9a19
260 changed files with 13089 additions and 0 deletions

534
Build/Automate/AddHosts.ps1 Normal file
View File

@ -0,0 +1,534 @@
# Script to add add ESX servers to vCenter and do initial configuration
#
#
# Version 0.9
#
#
if (Test-Path C:\PSFunctions.ps1) {
. "C:\PSFunctions.ps1"
} else {
Write-BuildLog "PSFunctions.ps1 not found. Please copy all PowerShell files from B:\Automate to C:\ and rerun AddHosts.ps1"
Read-Host "Press <Enter> 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 <Enter> 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") {
Write-BuildLog "Building Primary Site"
$HostPrefix = "host"
$DCName = "Lab"
$ClusterName = "Local"
$SRM = $False
}
If ($Subnet -eq "201") {
Write-BuildLog "Building SRM Site"
$HostPrefix = "host1"
$DCName = "SRM"
$ClusterName = "DR"
$SRM = $True
}
if ((Get-Service vpxd).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") {
Write-BuildLog "The vCenter service is stopped. Please verify the DC VM is powered on and databases have started."
Read-Host "Press <Enter> to exit"
exit
}
if ((Get-PSSnapin -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
}
catch {
Write-BuildLog "Unable to load the PowerCLI plugin. Please verify installation or install VMware PowerCLI and run this script again."
Read-Host "Press <Enter> to exit"
exit
}
}
for ($i=1;$i -le 4; $i++) {
$vmhost = "$HostPrefix$i.lab.local"
$ping = new-object System.Net.NetworkInformation.Ping
$Reply = $ping.send($vmhost)
if ($Reply.status eq "Success") {
$MaxHosts = $i
} else {
$i =4
}
}
If (!($MaxHosts -ge 2)){
Write-Host "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."
$AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9)
$createds = ((Select-String -SimpleMatch "BuildDatastores=" -Path "B:\Automate\automate.ini").line).substring(16).Trim()
$createvm = ((Select-String -SimpleMatch "BuildVM=" -Path "B:\Automate\automate.ini").line).substring(8).Trim()
$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."
} 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."
} 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."
} else {
$createxp = $false
}
} else {
Write-BuildLog "Unable to find B:\Automate\automate.ini. Where did it go?"
}
Write-BuildLog "Connect to vCenter; this takes a while and may show a warning in yellow"
try {
If ($SRM -eq $True) {$Connect = "vc2.lab.local"}
Else {$VCServer = "vc.lab.local"}
$Connect = Connect-VIServer $VCServer
}
catch {
Write-BuildLog "Unable to connect to vCenter. Exiting."
Read-Host "Press <Enter> to exit"
exit
}
Write-BuildLog "Create datacenter and cluster"
if ((Get-DataCenter | where {$_.Name -eq $DCName}) -eq $null) {
$newDC = New-DataCenter -Location (Get-Folder -NoRecursion) -Name $DCName
$dc = $newDC.ExtensionData.MoRef
$pool = New-Object VMware.Vim.IpPool
$pool.name = "MyIPPool"
$pool.ipv4Config = New-Object VMware.Vim.IpPoolIpPoolConfigInfo
$pool.ipv4Config.subnetAddress = "192.168.$Subnet.0"
$pool.ipv4Config.netmask = "255.255.255.0"
$pool.ipv4Config.gateway = "192.168.$Subnet.2"
$pool.ipv4Config.range = "192.168.$Subnet.200#16"
$pool.ipv4Config.dns = New-Object System.String[] (1)
$pool.ipv4Config.dns[0] = "192.168.$Subnet.4"
$pool.ipv4Config.dhcpServerAvailable = $false
$pool.ipv4Config.ipPoolEnabled = $true
$pool.ipv6Config = New-Object VMware.Vim.IpPoolIpPoolConfigInfo
$pool.ipv6Config.subnetAddress = ""
$pool.ipv6Config.netmask = "ffff:ffff:ffff:ffff:ffff:ffff::"
$pool.ipv6Config.gateway = ""
$pool.ipv6Config.dns = New-Object System.String[] (1)
$pool.ipv6Config.dns[0] = ""
$pool.ipv6Config.dhcpServerAvailable = $false
$pool.ipv6Config.ipPoolEnabled = $false
$pool.dnsDomain = ""
$pool.dnsSearchPath = ""
$pool.hostPrefix = ""
$pool.httpProxy = ""
$pool.networkAssociation = New-Object VMware.Vim.IpPoolAssociation[] (1)
$pool.networkAssociation[0] = New-Object VMware.Vim.IpPoolAssociation
$pool.networkAssociation[0].network = New-Object VMware.Vim.ManagedObjectReference
$pool.networkAssociation[0].network.type = "DistributedVirtualPortgroup"
$pool.networkAssociation[0].network.Value = "dvportgroup-178"
$pool.networkAssociation[0].networkName = ""
$PoolManager = Get-View -Id 'IpPoolManager-IpPoolManager'
$Nul = $PoolManager.CreateIpPool($dc, $pool)
}
if ((Get-Cluster | where {$_.Name -eq $ClusterName}) -eq $null) {
$Cluster = New-Cluster $ClusterName -DRSEnabled -Location $DCName -DRSAutomationLevel FullyAutomated
}
for ($i=1;$i -le $MaxHosts; $i++) {
$Num = $i +10
$VMHost = $HostPrefix
$VMHost += $i
$VMHost += ".lab.local"
$VMotionIP = "172.16.$SubNet."
$VMotionIP += $Num
$IPStoreIP1 = "172.17.$SubNet."
$IPStoreIP1 += $Num
$IPStoreIP2 = "172.17.$SubNet."
$Num = $i +20
$IPStoreIP2 += $Num
$FTIP = "172.16.$SubNet."
$FTIP += $Num
$Num = $i +40
$vHeartBeatIP = "172.16.$SubNet."
$vHeartBeatIP += $Num
Write-BuildLog $VMHost
if ((Get-VMHost | where {$_.Name -eq $VMHost}) -eq $null) {
$Null = Add-VMHost $VMhost -user root -password $AdminPWD -Location $ClusterName -force:$true
Start-Sleep -Seconds 30
try {
$null = Get-VMHost $VMHost
}
catch {
Write-BuildLog "Unable to find " $VMHost "; please verify the host is built and rerun the AddHosts script."
Read-Host "Press <Enter> to exit"
exit
}
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
if (($vmhostObj.ExtensionData.Config.Product.FullName.Contains("ESXi")) -and ((get-VmHostNtpServer $VMhostobj) -ne "192.168.199.4")) {
# These services aren't relevant on ESX Classic, only ESXi
$null = Add-VMHostNtpServer -NtpServer "192.168.199.4" -VMHost $VMhost
$ntp = Get-VMHostService -VMHost $VMhost | Where {$_.Key -eq "ntpd"}
$null = Set-VMHostService $ntp -Policy "On"
$SSH = Get-VMHostService -VMHost $VMhost | Where {$_.Key -eq "TSM-SSH"}
$null = Set-VMHostService $SSH -Policy "On"
$TSM = Get-VMHostService -VMHost $VMhost | Where {$_.Key -eq "TSM"}
$null = Set-VMHostService $TSM -Policy "On"
if ($vmhostObj.version.split(".")[0] -ne "4") {
if ($PCLIVerNum -ge 51) {
$null = Get-AdvancedSetting -Entity $VMHostObj -Name "UserVars.SuppressShellWarning" | Set-AdvancedSetting -Value "1" -confirm:$false
} else {
$null = Set-VMHostAdvancedConfiguration -vmhost $VMhost -Name "UserVars.SuppressShellWarning" -Value 1
}
}
}
$DSName = $VMHost.split('.')[0]
$DSName += "_Local"
$sharableIds = Get-ShareableDatastore | Foreach {$_.ID }
$null = Get-Datastore -vmhost $vmhost | Where {$sharableIds -notcontains $_.ID } | Set-DataStore -Name $DSName
$switch = Get-VirtualSwitch -vmHost $vmHostobj
if($switch -isnot [system.array]) {
Write-BuildLog " Configuring network."
$null = set-VirtualSwitch $switch -Nic vmnic0,vmnic1 -confirm:$false
$pg = New-VirtualPortGroup -Name vMotion -VirtualSwitch $switch
if ($vmhostObj.ExtensionData.Config.Product.FullName.Contains("ESXi")) {
$null = New-VMHostNetworkAdapter -VMHost $vmhost -Portgroup $pg -VirtualSwitch $switch -IP $VMotionIP -SubnetMask "255.255.255.0" -vMotionEnabled:$true -ManagementTrafficEnabled:$True
} else {
$null = New-VMHostNetworkAdapter -VMHost $vmhost -Portgroup $pg -VirtualSwitch $switch -IP $VMotionIP -SubnetMask "255.255.255.0" -vMotionEnabled:$true
$pg = New-VirtualPortGroup -Name vHeartBeat -VirtualSwitch $switch
$null = New-VMHostNetworkAdapter -VMHost $vmhost -Portgroup $pg -VirtualSwitch $switch -IP $vHeartBeatIP -SubnetMask "255.255.255.0" -ConsoleNIC
}
$pg = New-VirtualPortGroup -Name FT -VirtualSwitch $switch
$null = New-VMHostNetworkAdapter -VMHost $vmhost -Portgroup $pg -VirtualSwitch $switch -IP $FTIP -SubnetMask "255.255.255.0" -FaultToleranceLoggingEnabled:$true
$pg = New-VirtualPortGroup -Name IPStore1 -VirtualSwitch $switch
$null = New-VMHostNetworkAdapter -VMHost $vmhost -Portgroup $pg -VirtualSwitch $switch -IP $IPStoreIP1 -SubnetMask "255.255.255.0"
$pg = New-VirtualPortGroup -Name IPStore2 -VirtualSwitch $switch
$null = New-VMHostNetworkAdapter -VMHost $vmhost -Portgroup $pg -VirtualSwitch $switch -IP $IPStoreIP2 -SubnetMask "255.255.255.0"
$null = Get-VMHostStorage $VMHost | Set-VMHostStorage -SoftwareIScsiEnabled $true
$null = get-virtualportgroup -name vMotion | Get-NicTeamingPolicy | Set-NicTeamingPolicy -MakeNicActive vmnic1
$null = get-virtualportgroup -name vMotion | Get-NicTeamingPolicy | Set-NicTeamingPolicy -MakeNicStandby vmnic0
$pnic = (Get-VMhostNetworkAdapter -VMHost $VMHost -Physical)[2]
$switch = New-VirtualSwitch -VMhost $vmHost -Nic $pnic.DeviceName -NumPorts 128 -Name vSwitch1
$null = New-VirtualPortGroup -Name Servers -VirtualSwitch $switch
$null = New-VirtualPortGroup -Name Workstations -VirtualSwitch $switch
$null = set-VirtualSwitch $switch -Nic vmnic2,vmnic3 -confirm:$false
Start-Sleep -Seconds 30
If ($SRM -ne $True) {
Write-BuildLog " Add NFS datastores"
# Build datastore now added in unattend script
#$null = New-Datastore -nfs -VMhost $vmhost -Name Build -NFSHost "172.17.199.7" -Path "/mnt/LABVOL/Build" -readonly
$null = New-Datastore -nfs -VMhost $vmhost -Name NFS01 -NFSHost "172.17.199.7" -Path "/mnt/LABVOL/NFS01"
$null = New-Datastore -nfs -VMhost $vmhost -Name NFS02 -NFSHost "172.17.199.7" -Path "/mnt/LABVOL/NFS02"
}
if ($vmhostObj.version.split(".")[0] -ne "4") {
$null = remove-datastore -VMhost $vmhost -datastore remote-install-location -confirm:$false
}
Write-BuildLog " Configuring iSCSI"
$MyIQN = "iqn.1998-01.com.vmware:" + $VMHost.split('.')[0]
$null = Get-VMHostHba -VMhost $vmhost -Type iScsi | Set-VMHostHBA -IScsiName $MyIQN
If ($SRM -ne $True) {
$null = Get-VMHostHba -VMhost $vmhost -Type iScsi | New-IScsiHbaTarget -Address 172.17.199.7 -Type Send
$null = Get-VMHostStorage $VMHost -RescanAllHba
}
}
$null = Move-VMhost $VMHost -Destination $ClusterName
}
}
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"
$PingStatus = @()
for ($i=1;$i -le $MaxHosts; $i++) {$PingStatus +=$True}
do {
Start-Sleep -Seconds 1
$ping = new-object System.Net.NetworkInformation.Ping
for ($i=1;$i -le $MaxHosts; $i++) {
$VMHost = $HostPrefix
$VMHost += $i
$VMHost += ".lab.local"
If ((!(($ping.send($vmhost)).status eq "Success")) -and ($PingStatus[$I-1] -eq $True)) {$PingStatus[$I-1] = $False}
}
$StayHere = $False
for ($i=1;$i -le $MaxHosts; $i++) {
If ($PingStatus[$I-1] -eq $True) {$StayHere = $True}
}
} while ($StayHere)
Write-Host "Wait until all hosts are pinging"
do {
Start-Sleep -Seconds 1
$ping = new-object System.Net.NetworkInformation.Ping
for ($i=1;$i -le $MaxHosts; $i++) {
$VMHost = $HostPrefix
$VMHost += $i
$VMHost += ".lab.local"
If (($ping.send($vmhost)).status eq "Success") {$PingStatus[$I-1] = $True}
}
$StayHere = $False
for ($i=1;$i -le $MaxHosts; $i++) {
If ($PingStatus[$I-1] -eq $False) {$StayHere = $True}
}
} while ($StayHere)
Write-Host "Wait until all hosts are Connected"
for ($i=1;$i -le $MaxHosts; $i++) {$PingStatus +=$False}
do {
Start-Sleep -Seconds 1
for ($i=1;$i -le $MaxHosts; $i++) {
$VMHost = $HostPrefix
$VMHost += $i
$VMHost += ".lab.local"
If ((get-vmhost -name $VMHost).ConnectionState -eq "Connected" ) {$PingStatus[$I-1] = $True}
}
$StayHere = $False
for ($i=1;$i -le $MaxHosts; $i++) {
If ($PingStatus[$I-1] -eq $False) {$StayHere = $True}
}
} while ($StayHere)
Write-Host "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) ){
$null = New-OsCustomizationSpec -Name Windows -OSType Windows -FullName Lab -OrgName Lab.local -NamingScheme VM -ProductKey $ProdKey -LicenseMode PerSeat -AdminPass VMware1! -Workgroup Workgroup -ChangeSid -AutoLogonCount 999
}
if (((Get-OSCustomizationSpec | where {$_.Name -eq "WinXP"}) -eq $null) -and ($ProdKey -ne $null)) {
$null = New-OsCustomizationSpec -Name WinXP -OSType Windows -FullName Lab -OrgName Lab.local -NamingScheme VM -ProductKey $XPKey -LicenseMode PerSeat -AdminPass VMware1! -Workgroup Workgroup -ChangeSid -AutoLogonCount 999
}
$VMHostObj = Get-VMHost $VMHost
If (($VMHostObj.Version.Split("."))[0] -eq "6") {
$MinVMFSVer = 5
} Else {
$MinVMFSVer = 3
}
if ($CreateDS) {
Write-BuildLog "Creating iSCSI datastores."
$iSCSILUNs = get-scsilun -vmhost $VMHost -CanonicalName "t10.*"
if ($vmhostobj.version.split(".")[0] -ne "4") {
if (((Get-Datastore | where {$_.Name -eq "iSCSI1"}) -eq $null) ) {
$null = New-Datastore -VMHost $VMHost -Name iSCSI1 -Path $iSCSILUNs[0].CanonicalName -Vmfs -FileSystemVersion 5
Write-BuildLog "Created iSCSi1 Datstore"
} else {
Write-BuildLog "Registering all VMs found on existing datastore iSCSI1."
Register-VMs ("iSCSI1")
}
}
if ((Get-Datastore | where {$_.Name -eq "iSCSI2"}) -eq $null) {
$null = New-Datastore -VMHost $VMHost -Name iSCSI2 -Path $iSCSILUNs[1].CanonicalName -Vmfs -FileSystemVersion $MinVMFSVer
Write-BuildLog "Created iSCSi2 Datastore"
} else {
Write-BuildLog "Registering all VMs found on existing datastore iSCSI2."
Register-VMs ("iSCSI2")
}
if ((Get-Datastore | where {$_.Name -eq "iSCSI3"}) -eq $null) {
$null = New-Datastore -VMHost $VMHost -Name iSCSI3 -Path $iSCSILUNs[2].CanonicalName -Vmfs -FileSystemVersion $MinVMFSVer
Write-BuildLog "Created iSCSi3 datstore"
} else {
Write-BuildLog "Registering all VMs found on existing datastore iSCSI3"
Register-VMs ("iSCSI3")
}
}
Write-BuildLog "Setting up HA on cluster since shared storage is configured."
$Cluster = Get-Cluster -Name $ClusterName
$null = set-cluster -cluster $Cluster -HAEnabled:$True -HAAdmissionControlEnabled:$True -confirm:$false
$null = New-AdvancedSetting -Entity $cluster -Type ClusterHA -Name 'das.isolationaddress1' -Value "192.168.$SubNet.4" -confirm:$false -force
$null = New-AdvancedSetting -Entity $cluster -Type ClusterHA -Name 'das.isolationaddress2' -Value "172.17.$SubNet.7" -confirm:$false -force
$null = New-AdvancedSetting -Entity $cluster -Type ClusterHA -Name 'das.usedefaultisolationaddress' -Value false -confirm:$false -force
$spec = New-Object VMware.Vim.ClusterConfigSpecEx
$null = $spec.dasConfig = New-Object VMware.Vim.ClusterDasConfigInfo
$null = $spec.dasConfig.admissionControlPolicy = New-Object VMware.Vim.ClusterFailoverResourcesAdmissionControlPolicy
$null = $spec.dasConfig.admissionControlPolicy.cpuFailoverResourcesPercent = 50
$null = $spec.dasConfig.admissionControlPolicy.memoryFailoverResourcesPercent = 50
$Cluster = Get-View $Cluster
$null = $Cluster.ReconfigureComputeResource_Task($spec, $true)
Write-BuildLog "Waiting two minutes for HA to complete configuration."
Start-Sleep -Seconds 120
$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."
}
}
Start-Sleep -Seconds 2
$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."
$Datastore = Get-Datastore "Build"
if (!(Get-PSDrive -Name Build -ErrorAction "SilentlyContinue")) {
$null = New-PSDrive -Name Build -PSProvider ViMdatastore -Root '\' -Location $Datastore
}
$Datastore = Get-Datastore "iSCSI3"
if (!(Get-PSDrive -Name iSCSI3 -ErrorAction "SilentlyContinue")) {
$null = New-PSDrive -Name iSCSI3 -PSProvider ViMdatastore -Root '\' -Location $Datastore
}
if (!(Test-Path iSCSI3:/TTYLinux/TTYLinux.vmx)) {
Write-BuildLog "Copying TTYLinux VM to iSCSI3 datastore."
$Datastore = Get-Datastore "iSCSI3"
Copy-DatastoreItem Build:/Automate/ShellVMs/TTYLinux iSCSI3:\ -recurse
}
$vmxFile = Get-Item iSCSI3:/TTYLinux/TTYLinux.vmx
$null= New-VM -VMFilePath $VMXFile.DatastoreFullPath -VMHost $vmhost -Location "vm" -name "TTYLinux"
Start-Sleep -Seconds 2
$null = Remove-PSDrive Build
$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 <Enter> to continue."
}
exit

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,23 @@
@echo off
echo *************************
echo *
echo **
echo * Connect to build share
net use B: \\192.168.199.7\Build >> c:\buildlog.txt
type b:\automate\version.txt >> c:\buildlog.txt
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\IExplorer.reg
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
echo * Activate Windows >> c:\buildlog.txt
cscript //B "%windir%\system32\slmgr.vbs" /ato
copy B:\Automate\PSFunctions.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

View File

@ -0,0 +1,76 @@
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 Build.ps1"
Read-Host "Press <Enter> to exit"
exit
}
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."
tzutil /s "$timezone"
$AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9)
}
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
Write-BuildLog "Disabling screen saver"
set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0
}
$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}
}
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
}
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
}
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
}
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
}
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
}
}
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"
Read-Host "Rebooting after VMTools Install"

View File

@ -0,0 +1,10 @@
set WshShell = WScript.CreateObject("WScript.Shell")
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\BuildLog.lnk")
oShortCutLink.TargetPath = "c:\BuildLog.txt"
oShortCutLink.Save
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\View Setup.lnk")
oShortCutLink.TargetPath = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"
oShortCutLink.Arguments = " c:\ViewSetup.ps1"
oShortCutLink.Save

View File

@ -0,0 +1,21 @@
@echo off
echo *************************
echo *
echo **
echo * Connect to build share
net use B: \\192.168.199.7\Build >> c:\buildlog.txt
type b:\automate\version.txt >> c:\buildlog.txt
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\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_DWORD /D 1 /F
echo * Activate Windows >> c:\buildlog.txt
cscript //B "%windir%\system32\slmgr.vbs" /ato
copy B:\Automate\PSFunctions.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

View File

@ -0,0 +1,84 @@
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 Build.ps1"
Read-Host "Press <Enter> to exit"
exit
}
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."
tzutil /s "$timezone"
$AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9)
}
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
Write-BuildLog "Disabling screen saver"
set-ItemProperty -path 'HKCU:\Control Panel\Desktop' -name ScreenSaveActive -value 0
}
if (Test-Path "C:\VMware-view*") {
$Files = get-childitem "C:\"
for ($i=0; $i -lt $files.Count; $i++) {
If ($Files[$i].Name -like "VMware-view*") {$Installer = $Files[$i].FullName}
}
switch ($viewinstall) {
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
}
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
}
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
}
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
}
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
}
}
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f
Exit
}
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 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
Write-BuildLog "Install VMware Tools"
b:\VMTools\Setup64.exe /s /v "/qn"
Read-Host "Reboot?"

View File

@ -0,0 +1,10 @@
set WshShell = WScript.CreateObject("WScript.Shell")
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\BuildLog.lnk")
oShortCutLink.TargetPath = "c:\BuildLog.txt"
oShortCutLink.Save
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\View Setup.lnk")
oShortCutLink.TargetPath = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"
oShortCutLink.Arguments = " c:\ViewSetup.ps1"
oShortCutLink.Save

View File

@ -0,0 +1,7 @@
#Install-Windowsfeature AD-Domain-Services,DNS -IncludeManagementTools
Add-WindowsFeature -name ad-domain-services -IncludeManagementTools
Write-Host "Convertto-SecureString"
$safemodeadminpwd = ConvertTo-SecureString -String "VMware1!" -asplaintext -force
Write-Host "Install-ADDSForest"
Install-ADDSForest -DomainName "lab.local" -ForestMode Win2008R2 -DomainMode Win2008R2 -SafeModeAdministratorPassword $safemodeadminpwd -Force

View File

@ -0,0 +1,9 @@
[DCInstall]
InstallDNS = yes
DomainNetBiosName = lab
NewDomain=forest
NewDomainDNSName = lab.local
RebootOnCompletion = yes
ReplicaOrNewDomain = Domain
SiteName = "Lab"
SafeModeAdminPassword="VMware1!"

View File

@ -0,0 +1,18 @@
drop database vCenter
go
drop database VUM
go
drop database ViewEvents
go
drop database ViewComposer
go
drop database SRM
go
drop database SRMRep
go
drop database RSA
go
drop database vCloud51
go
drop database vCloud15
go

View File

@ -0,0 +1,89 @@
Create Login vpx WITH PASSWORD = 'VMware1!'
Go
create Database vCenter
Go
use vCenter
go
sp_addrolemember @rolename = 'db_owner', @membername = 'vpx'
go
use MSDB
go
sp_addrolemember @rolename = 'db_owner', @membername = 'vpx'
go
use master
go
sp_addrolemember @rolename = 'db_owner', @membername = 'vpx'
go
grant VIEW SERVER STATE to vpx
go
GRANT VIEW ANY DEFINITION TO vpx
go
create database VUM
GO
ALTER AUTHORIZATION ON DATABASE::vCenter TO vpx
ALTER AUTHORIZATION ON DATABASE::VUM TO vpx
ALTER AUTHORIZATION ON DATABASE::msdb TO vpx
Go
Create Login VMview WITH PASSWORD = 'VMware1!'
Go
create database ViewEvents
GO
create database ViewComposer
GO
ALTER AUTHORIZATION ON DATABASE::ViewEvents TO VMview
ALTER AUTHORIZATION ON DATABASE::ViewComposer TO VMview
go
Create Login VMSRM WITH PASSWORD = 'VMware1!'
Go
create database SRM
GO
create database SRMRep
GO
ALTER AUTHORIZATION ON DATABASE::SRM TO VMSRM
ALTER AUTHORIZATION ON DATABASE::SRMRep TO VMSRM
Go
EXEC master..sp_addsrvrolemember @loginame = 'lab\VI-admin', @rolename = 'sysadmin'
Go
EXEC master..sp_addsrvrolemember @loginame = 'lab\SVC_Veeam', @rolename = 'sysadmin'
Go
USE MASTER
GO
CREATE DATABASE RSA ON PRIMARY(
NAME='RSA_DATA',
FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\RSA_DATA.mdf',
SIZE=10MB,
MAXSIZE=UNLIMITED,
FILEGROWTH=10%),
FILEGROUP RSA_INDEX(
NAME='RSA_INDEX',
FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\RSA_INDEX.ndf',
SIZE=10MB,
MAXSIZE=UNLIMITED,
FILEGROWTH=10%)
LOG ON(
NAME='translog',
FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\translog.ldf',
SIZE=10MB,
MAXSIZE=UNLIMITED,
FILEGROWTH=10% )
GO
SP_DBOPTION 'RSA', 'autoshrink', true
GO
EXEC SP_DBOPTION 'RSA', 'trunc. log on chkpt.', true
GO
CHECKPOINT
GO
USE MASTER
GO
CREATE LOGIN RSA_DBA WITH PASSWORD = 'VMware1!', DEFAULT_DATABASE = RSA
GO
CREATE LOGIN RSA_USER WITH PASSWORD = 'VMware1!', DEFAULT_DATABASE = RSA
GO
USE RSA
GO
ALTER AUTHORIZATION ON DATABASE::RSA TO [RSA_DBA]
GO
CREATE USER RSA_USER FOR LOGIN [RSA_USER]
GO
CHECKPOINT
GO

View File

@ -0,0 +1,32 @@
Create Login vpx WITH PASSWORD = 'VMware1!'
Go
create Database vCenter
Go
create database VUM
GO
ALTER AUTHORIZATION ON DATABASE::vCenter TO vpx
ALTER AUTHORIZATION ON DATABASE::VUM TO vpx
ALTER AUTHORIZATION ON DATABASE::msdb TO vpx
Go
Create Login VMview WITH PASSWORD = 'VMware1!'
Go
create database ViewEvents
GO
create database ViewComposer
GO
ALTER AUTHORIZATION ON DATABASE::ViewEvents TO VMview
ALTER AUTHORIZATION ON DATABASE::ViewComposer TO VMview
go
Create Login VMSRM WITH PASSWORD = 'VMware1!'
Go
create database SRM
GO
create database SRMRep
GO
ALTER AUTHORIZATION ON DATABASE::SRM TO VMSRM
ALTER AUTHORIZATION ON DATABASE::SRMRep TO VMSRM
Go
EXEC master..sp_addsrvrolemember @loginame = 'lab\VI-admin', @rolename = 'sysadmin'
Go
EXEC master..sp_addsrvrolemember @loginame = 'lab\SVC_Veeam', @rolename = 'sysadmin'
Go

View File

@ -0,0 +1,26 @@
USE [master]
GO
CREATE DATABASE [vCloud15] ON PRIMARY
(NAME = N'vCloud15', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\vCloud15.mdf', SIZE = 100MB, FILEGROWTH = 10% )
LOG ON
(NAME = N'vcdb_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\vCloud15.ldf', SIZE = 1MB, FILEGROWTH = 10%)
COLLATE Latin1_General_CS_AS
GO
USE [vCloud15]
GO
ALTER DATABASE [vCloud15] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE [vCloud15] SET ALLOW_SNAPSHOT_ISOLATION ON;
ALTER DATABASE [vCloud15] SET READ_COMMITTED_SNAPSHOT ON WITH NO_WAIT;
ALTER DATABASE [vCloud15] SET MULTI_USER;
GO
USE [vCloud15]
GO
CREATE LOGIN [vCloud15] WITH PASSWORD = 'VMware1!', DEFAULT_DATABASE =[vCloud15],
DEFAULT_LANGUAGE =[us_english], CHECK_POLICY=OFF
GO
CREATE USER [vCloud15] for LOGIN [vCloud15]
GO
USE [vCloud15]
GO
sp_addrolemember [db_owner], [vCloud15]
GO

View File

@ -0,0 +1,26 @@
USE [master]
GO
CREATE DATABASE [vCloud51] ON PRIMARY
(NAME = N'vCloud51', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\vCloud51.mdf', SIZE = 100MB, FILEGROWTH = 10% )
LOG ON
(NAME = N'vcdb_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\vCloud51.ldf', SIZE = 1MB, FILEGROWTH = 10%)
COLLATE Latin1_General_CS_AS
GO
USE [vCloud51]
GO
ALTER DATABASE [vCloud51] SET SINGLE_USER WITH ROLLBACK IMMEDIATE;
ALTER DATABASE [vCloud51] SET ALLOW_SNAPSHOT_ISOLATION ON;
ALTER DATABASE [vCloud51] SET READ_COMMITTED_SNAPSHOT ON WITH NO_WAIT;
ALTER DATABASE [vCloud51] SET MULTI_USER;
GO
USE [vCloud51]
GO
CREATE LOGIN [vcloud51] WITH PASSWORD = 'VMware1!', DEFAULT_DATABASE =[vCloud51],
DEFAULT_LANGUAGE =[us_english], CHECK_POLICY=OFF
GO
CREATE USER [vcloud51] for LOGIN [vcloud51]
GO
USE [vCloud51]
GO
sp_addrolemember [db_owner], [vcloud51]
GO

View File

@ -0,0 +1,52 @@
@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_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
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 **
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
echo **
echo * Copy PowerShell files
echo * Copy PowerShell files >> c:\buildlog.txt
copy B:\Automate\validate.ps1 C:\
copy B:\Automate\PSFunctions.ps1 C:\
copy B:\Automate\PXEMenuConfig.ps1 C:\
copy B:\Automate\DC\Phase2.ps1 C:\
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
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 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

View File

@ -0,0 +1,631 @@
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 Build.ps1"
Read-Host "Press <Enter> to exit"
exit
}
# Start DC configuration process
if (Test-Path B:\Automate\automate.ini) {
$KMSIP = "0.0.0.0"
$KMSIP = ((Select-String -SimpleMatch "KMSIP=" -Path "B:\Automate\automate.ini").line).substring(6)
$AdminPWD = "VMware1!"
$AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9)
Write-BuildLog "Setup Users"
NET ACCOUNTS /MAXPWAGE:UNLIMITED >> C:\AD-Users.log 2>> C:\Error.log
net group "Domain Admins" vi-admin /add >> C:\AD-Users.log 2>> C:\Error.log
net user SVC_Veeam $AdminPWD /add /Domain >> C:\AD-Users.log 2>> C:\Error.log
net group "Domain Admins" SVC_Veeam /add >> C:\AD-Users.log 2>> C:\Error.log
net user SVC_SRM $AdminPWD /add /Domain >> C:\AD-Users.log 2>> C:\Error.log
net group "Domain Admins" SVC_SRM /add >> C:\AD-Users.log 2>> C:\Error.log
net user SVC_vCD $AdminPWD /add /Domain >> C:\AD-Users.log 2>> C:\Error.log
net group "Domain Admins" SVC_vCD /add >> C:\AD-Users.log 2>> C:\Error.log
net group "ESX Admins" /add >> C:\AD-Users.log 2>> C:\Error.log
net group "ESX Admins" vi-admin /add >> C:\AD-Users.log 2>> C:\Error.log
net user DomUser $AdminPWD /add /domain >> C:\AD-Users.log 2>> C:\Error.log
net user vi-admin $AdminPWD >> C:\AD-Users.log 2>> C:\Error.log
net user JoinUser VMware1! /add /domain >> C:\AD-Users.log 2>> C:\Error.log
net group "DHCP Administrators" /add >> C:\AD-Users.log 2>> C:\Error.log
net group "DHCP Users" /add >> C:\AD-Users.log 2>> C:\Error.log
dsadd OU "ou=LAB,DC=lab,DC=local"
dsadd OU "ou=Users,ou=LAB,DC=lab,DC=local"
dsadd OU "ou=Groups,ou=LAB,DC=lab,DC=local"
dsadd Group "cn=Lab Staff,ou=Groups,ou=LAB,DC=lab,DC=local" -desc "All staff of the LAB"
dsadd OU "ou=Servers,ou=LAB,DC=lab,DC=local"
dsadd OU "ou=Workstationsou=LAB,DC=lab,DC=local"
dsadd user "cn=grace,ou=Users,ou=LAB,DC=lab,DC=local" -disabled no -pwd $AdminPWD -upn grace@lab.local -fn Grace -ln Hopper -display "Grace Hopper" -email grace@lab.local -memberof "cn=Lab Staff,ou=Groups,ou=LAB,DC=lab,DC=local"
dsadd user "cn=ada,ou=Users,ou=LAB,DC=lab,DC=local" -disabled no -pwd $AdminPWD -upn ada@lab.local -fn Ada -ln Lovelace -display "Ada Lovelace" -email ada@lab.local -memberof "cn=Lab Staff,ou=Groups,ou=LAB,DC=lab,DC=local"
dsadd user "cn=alan,ou=Users,ou=LAB,DC=lab,DC=local" -disabled no -pwd $AdminPWD -upn alan@lab.local -fn Alan -ln Turing -display "Alan Turing" -email alan@lab.local -memberof "cn=Lab Staff,ou=Groups,ou=LAB,DC=lab,DC=local"
dsadd user "cn=charles,ou=Users,ou=LAB,DC=lab,DC=local" -disabled no -pwd $AdminPWD -upn charles@lab.local -fn Charles -ln Babbage -display "Charles Babbage" -email charles@lab.local -memberof "cn=Lab Staff,ou=Groups,ou=LAB,DC=lab,DC=local"
Write-BuildLog "Change default local administrator password"
net user administrator $AdminPWD
B:\automate\_Common\Autologon administrator lab $AdminPWD
} Else {
Write-BuildLog "Cannot find Automate.ini, this isn't a good sign"
}
Write-BuildLog "Installing 7-zip."
try {
msiexec /qb /i B:\Automate\_Common\7z920-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"}
Rename-Item B:\VMware-PowerCLI.exe B:\VMware-PowerCLI-$PowCLIver.exe
}
if (Test-Path "C:\Program Files\Tftpd64_SE\Tftpd64_SVC.exe") {
Write-BuildLog "Found TFTP, not installing."
}Else {
Write-BuildLog "Installing TFTP."
Write-BuildLog "Creating C:\TFTP-Root directory."
$null = $null = New-Item -Path C:\TFTP-Root -ItemType Directory -Force -Confirm:$false
Write-BuildLog "Creating C:\Program Files\Tftpd64_SE directory."
$null = $null = New-Item -Path "C:\Program Files\Tftpd64_SE" -ItemType Directory -Force -Confirm:$false
xcopy B:\Automate\DC\Tftpd64_SE\*.* "C:\Program Files\Tftpd64_SE\" /s /c /y /q
Start-Sleep -Seconds 30
Start-Process "C:\Program Files\Tftpd64_SE\Tftpd64_SVC.exe" -ArgumentList "-install" -Wait
Write-BuildLog "Setting TFTP service startup type and starting it."
$null = Set-Service -Name "Tftpd32_svc" -StartupType "Automatic"
$null = Start-Service -Name "Tftpd32_svc"
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"
$TempContent = Get-Content B:\Automate\Hosts\esx1-4.cfg |%{$_ -replace "VMware1!",$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx1-4.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx1-5.cfg |%{$_ -replace "VMware1!",$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx1-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx2-4.cfg |%{$_ -replace "VMware1!",$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx2-4.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx2-4c.cfg |%{$_ -replace "VMware1!",$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx2-4c.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx2-5.cfg |%{$_ -replace "VMware1!",$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx2-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx3-5.cfg |%{$_ -replace "VMware1!",$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx3-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx4-5.cfg |%{$_ -replace "VMware1!",$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx4-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx11-5.cfg |%{$_ -replace "VMware1!",$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx11-5.cfg
$TempContent = Get-Content B:\Automate\Hosts\esx12-5.cfg |%{$_ -replace "VMware1!",$AdminPWD}
$TempContent | Set-Content B:\Automate\Hosts\esx12-5.cfg
Write-BuildLog "Checking for vSphere files..."
if (Test-Path "B:\ESXi60\*") {
if (Test-Path "B:\ESXi60\*.iso") {
Write-BuildLog "Extracting ESXi 6.0 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESXi60\ B:\ESXi60\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESXi 6.0 found; creating C:\TFTP-Root\ESXi60 and copying ESXi 6.0 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESXi60 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESXi60\*.* C:\TFTP-Root\ESXi60 /s /c /y /q
Get-Content C:\TFTP-Root\ESXi60\BOOT.CFG | %{$_ -replace "/","/ESXi60/"} | Set-Content C:\TFTP-Root\ESXi60\Besx1-60.cfg
Add-Content C:\TFTP-Root\ESXi60\\Besx1-60.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx1-5.cfg"
Get-Content C:\TFTP-Root\ESXi60\BOOT.CFG | %{$_ -replace "/","/ESXi60/"} | Set-Content C:\TFTP-Root\ESXi60\Besx2-60.cfg
Add-Content C:\TFTP-Root\ESXi60\\Besx2-60.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx2-5.cfg"
Get-Content C:\TFTP-Root\ESXi60\BOOT.CFG | %{$_ -replace "/","/ESXi60/"} | Set-Content C:\TFTP-Root\ESXi60\Besx3-60.cfg
Add-Content C:\TFTP-Root\ESXi60\Besx3-60.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg"
Get-Content C:\TFTP-Root\ESXi60\BOOT.CFG | %{$_ -replace "/","/ESXi60/"} | Set-Content C:\TFTP-Root\ESXi60\Besx4-60.cfg
Add-Content C:\TFTP-Root\ESXi60\\Besx4-60.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg"
powershell C:\PXEMenuConfig.ps1 ESXi60
Write-BuildLog "ESXi 6.0 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi60 = $true
} else {
$esxi60 = $false
}
if (Test-Path "B:\ESXi55\*") {
if (Test-Path "B:\ESXi55\*.iso") {
Write-BuildLog "Extracting ESXi 5.5 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESXi55\ B:\ESXi55\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESXi 5.5 found; creating C:\TFTP-Root\ESXi55 and copying ESXi 5.5 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESXi55 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESXi55\*.* C:\TFTP-Root\ESXi55 /s /c /y /q
Get-Content C:\TFTP-Root\ESXi55\BOOT.CFG | %{$_ -replace "/","/ESXi55/"} | Set-Content C:\TFTP-Root\ESXi55\Besx1-55.cfg
Add-Content C:\TFTP-Root\ESXi55\\Besx1-55.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx1-5.cfg"
Get-Content C:\TFTP-Root\ESXi55\BOOT.CFG | %{$_ -replace "/","/ESXi55/"} | Set-Content C:\TFTP-Root\ESXi55\Besx2-55.cfg
Add-Content C:\TFTP-Root\ESXi55\\Besx2-55.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx2-5.cfg"
Get-Content C:\TFTP-Root\ESXi55\BOOT.CFG | %{$_ -replace "/","/ESXi55/"} | Set-Content C:\TFTP-Root\ESXi55\Besx3-55.cfg
Add-Content C:\TFTP-Root\ESXi55\Besx3-55.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg"
Get-Content C:\TFTP-Root\ESXi55\BOOT.CFG | %{$_ -replace "/","/ESXi55/"} | Set-Content C:\TFTP-Root\ESXi55\Besx4-55.cfg
Add-Content C:\TFTP-Root\ESXi55\\Besx4-55.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg"
powershell C:\PXEMenuConfig.ps1 ESXi55
Write-BuildLog "ESXi 5.5 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi55 = $true
} else {
$esxi55 = $false
}
if (Test-Path "B:\ESXi51\*") {
if (Test-Path "B:\ESXi51\*.iso") {
Write-BuildLog "Extracting ESXi 5.1 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESXi51\ B:\ESXi51\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESXi 5.1 found; creating C:\TFTP-Root\ESXi51 and copying ESXi 5.1 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESXi51 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESXi51\*.* C:\TFTP-Root\ESXi51 /s /c /y /q
Get-Content C:\TFTP-Root\ESXi51\BOOT.CFG | %{$_ -replace "/","/ESXi51/"} | Set-Content C:\TFTP-Root\ESXi51\Besx1-5.cfg
Add-Content C:\TFTP-Root\ESXi51\Besx1-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx1-5.cfg"
Get-Content C:\TFTP-Root\ESXi51\BOOT.CFG | %{$_ -replace "/","/ESXi51/"} | Set-Content C:\TFTP-Root\ESXi51\Besx2-5.cfg
Add-Content C:\TFTP-Root\ESXi51\Besx2-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx2-5.cfg"
Get-Content C:\TFTP-Root\ESXi51\BOOT.CFG | %{$_ -replace "/","/ESXi51/"} | Set-Content C:\TFTP-Root\ESXi51\Besx3-5.cfg
Add-Content C:\TFTP-Root\ESXi51\Besx3-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg"
Get-Content C:\TFTP-Root\ESXi51\BOOT.CFG | %{$_ -replace "/","/ESXi51/"} | Set-Content C:\TFTP-Root\ESXi51\Besx4-5.cfg
Add-Content C:\TFTP-Root\ESXi51\Besx4-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg"
powershell C:\PXEMenuConfig.ps1 ESXi51
Write-BuildLog "ESXi 5.1 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi51 = $true
} else {
$esxi51 = $false
}
if (Test-Path "B:\ESXi50\*") {
if (Test-Path "B:\ESXi50\*.iso") {
Write-BuildLog "Extracting ESXi 5.0 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESXi50\ B:\ESXi50\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESXi 5.0 found; creating C:\TFTP-Root\ESXi50 and copying ESXi 5.0 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESXi50 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESXi50\*.* C:\TFTP-Root\ESXi50 /s /c /y /q
Get-Content C:\TFTP-Root\ESXi50\BOOT.CFG | %{$_ -replace "/","/ESXi50/"} | Set-Content C:\TFTP-Root\ESXi50\Besx1-5.cfg
Add-Content C:\TFTP-Root\ESXi50\Besx1-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx1-5.cfg"
Get-Content C:\TFTP-Root\ESXi50\BOOT.CFG | %{$_ -replace "/","/ESXi50/"} | Set-Content C:\TFTP-Root\ESXi50\Besx2-5.cfg
Add-Content C:\TFTP-Root\ESXi50\Besx2-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx2-5.cfg"
Get-Content C:\TFTP-Root\ESXi50\BOOT.CFG | %{$_ -replace "/","/ESXi50/"} | Set-Content C:\TFTP-Root\ESXi50\Besx3-5.cfg
Add-Content C:\TFTP-Root\ESXi50\Besx3-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg"
Get-Content C:\TFTP-Root\ESXi50\BOOT.CFG | %{$_ -replace "/","/ESXi50/"} | Set-Content C:\TFTP-Root\ESXi50\Besx4-5.cfg
Add-Content C:\TFTP-Root\ESXi50\Besx4-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg"
powershell C:\PXEMenuConfig.ps1 ESXi50
Write-BuildLog "ESXi 5.0 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi50 = $true
} else {
$esxi50 = $false
}
if (Test-Path "B:\ESXi41\*") {
if (Test-Path "B:\ESXi41\*.iso") {
Write-BuildLog "Extracting ESXi 4.1 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESXi41\ B:\ESXi41\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESXi 4.1 found; creating C:\TFTP-Root\ESXi41 and copying ESXi 4.1 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESXi41 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESXi41\vmkboot.gz C:\TFTP-Root\ESXi41 /s /c /y /q
xcopy B:\ESXi41\vmkernel.gz C:\TFTP-Root\ESXi41 /s /c /y /q
xcopy B:\ESXi41\sys.vgz C:\TFTP-Root\ESXi41 /s /c /y /q
xcopy B:\ESXi41\cim.vgz C:\TFTP-Root\ESXi41 /s /c /y /q
xcopy B:\ESXi41\ienviron.vgz C:\TFTP-Root\ESXi41 /s /c /y /q
xcopy B:\ESXi41\install.vgz C:\TFTP-Root\ESXi41 /s /c /y /q
xcopy B:\ESXi41\mboot.c32 C:\TFTP-Root\ESXi41 /s /c /y /q
powershell C:\PXEMenuConfig.ps1 ESXi41
Write-BuildLog "ESXi 4.1 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi41 = $true
} else {
$esxi41 = $false
}
if (Test-Path "B:\ESX41\*") {
if (Test-Path "B:\ESX41\*.iso") {
Write-BuildLog "Extracting ESX 4.1 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESX41\ B:\ESX41\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESX 4.1 found; creating C:\TFTP-Root\ESX41 and copying ESX 4.1 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESX41 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESX41\isolinux\vmlinuz C:\TFTP-Root\ESX41 /s /c /y /q
xcopy B:\ESX41\isolinux\initrd.img C:\TFTP-Root\ESX41 /s /c /y /q
powershell C:\PXEMenuConfig.ps1 ESX41
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)) {
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."
exit
}
Write-BuildLog "Checking for vCenter files..."
if (Test-Path "B:\VIM_60\*") {
if (Test-Path "B:\VIM_60\*.iso") {
Write-BuildLog "Extracting vCenter 6.0 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VIM_60\ B:\VIM_60\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "vCenter 6.0 found."
$vCenter60 = $true
} else {
$vCenter60 = $false
}
if (Test-Path "B:\VIM_55\*") {
if (Test-Path "B:\VIM_55\*.iso") {
Write-BuildLog "Extracting vCenter 5.5 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VIM_55\ B:\VIM_55\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "vCenter 5.5 found."
$vCenter55 = $true
} else {
$vCenter55 = $false
}
if (Test-Path "B:\VIM_51\*") {
if (Test-Path "B:\VIM_51\*.iso") {
Write-BuildLog "Extracting vCenter 5.1 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VIM_51\ B:\VIM_51\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "vCenter 5.1 found."
$vCenter51 = $true
} else {
$vCenter51 = $false
}
if (Test-Path "B:\VIM_50\*") {
if (Test-Path "B:\VIM_50\*.iso") {
Write-BuildLog "Extracting vCenter 5.0 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VIM_50\ B:\VIM_50\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "vCenter 5.0 found."
$vCenter50 = $true
} else {
$vCenter50 = $false
}
if (Test-Path "B:\VIM_41\*") {
if (Test-Path "B:\VIM_41\*.iso") {
Write-BuildLog "Extracting vCenter 4.1 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VIM_41\ B:\VIM_41\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "vCenter 4.1 found."
$vCenter41 = $true
} else {
$vCenter41 = $false
}
if (!($vCenter41 -or $vCenter50 -or $vCenter51 -or $vCenter55 -or $vCenter60)) {
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 (!($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."
$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."
$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."
$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."
$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."
$vSphere41 = $false
} else {
$vSphere41 = $true
}
if (!($vSphere41 -or $vSphere50 -or $vSphere51 -or $vSphere55 -or $vSphere60)) {
Write-BuildLog "Matching vCenter & ESXi distributions not found. Please check the Build share."
}
Write-BuildLog ""
Write-BuildLog "Checking for vCloud files..."
if (Test-Path "B:\vCD_51\vmware-vcloud-director-5.1*.bin") {
Write-BuildLog "vCloud Director 5.1 found."
$vcd51 = $true
} else {
$vcd51 = $false
}
if (Test-Path "B:\vCD_51\VMware-vShield-Manager-5.1*.ova") {
Write-BuildLog "vShield Manager 5.1 for vCloud Director 5.1 found."
$vcd51vsm = $true
} else {
$vcd51vsm = $false
}
if ($vcd51 -and $vcd51vsm) {
powershell C:\PXEMenuConfig.ps1 vCloud
powershell C:\PXEMenuConfig.ps1 vCD51
Write-BuildLog "Added vCloud Director 5.1 to PXE menu."
} elseif ($vcd51 -or $vcd51vsm) {
Write-BuildLog "vCloud 5.1 installation requirements not met. Please verify that both vCloud 5.1 & vShield Manager 5.1 exist on the Build share."
}
if (Test-Path "B:\vCD_15\vmware-vcloud-director-1.5*.bin") {
Write-BuildLog "vCloud Director 1.5 found."
$vcd15 = $true
} else {
$vcd15 = $false
}
if (Test-Path "B:\vCD_15\VMware-vShield-Manager-5.0*.ova") {
Write-BuildLog "vShield Manager 5.0 for vCloud Director 1.5 found."
$vcd15vsm = $true
} else {
$vcd15vsm = $false
}
if ($vcd15 -and $vcd15vsm) {
powershell C:\PXEMenuConfig.ps1 vCloud
powershell C:\PXEMenuConfig.ps1 vCD15
Write-BuildLog "Added vCloud Director 1.5 to PXE menu."
} elseif ($vcd15 -or $vcd15vsm) {
Write-BuildLog "vCloud 1.5 installation requirements not met. Please verify that both vCloud 1.5 & vShield Manager 5.0 exist on 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
Write-BuildLog "Create DNS Records"
dnscmd localhost /config /UpdateOptions 0x0 >> C:\DNS.log
dnscmd localhost /config lab.local /allowupdate 1 >> C:\DNS.log
dnscmd localhost /zoneadd 199.168.192.in-addr.arpa /DsPrimary >> C:\DNS.log
dnscmd localhost /zoneadd 201.168.192.in-addr.arpa /DsPrimary >> C:\DNS.log
dnscmd localhost /config 199.168.192.in-addr.arpa /allowupdate 1 >> C:\DNS.log
dnscmd localhost /config 201.168.192.in-addr.arpa /allowupdate 1 >> C:\DNS.log
dnscmd localhost /resetforwarders 192.168.199.2 /slave >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local GW A 192.168.199.2 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local VC A 192.168.199.5 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local VMA A 192.168.199.6 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local NAS A 192.168.199.7 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local Host1 A 192.168.199.11 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local Host2 A 192.168.199.12 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local Host3 A 192.168.199.13 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local Host4 A 192.168.199.14 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local CS1 A 192.168.199.33 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local CS2 A 192.168.199.34 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local SS A 192.168.199.35 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local V1 A 192.168.199.36 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local VBR A 192.168.199.37 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local vcd A 192.168.199.38 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local vcd-proxy A 192.168.199.39 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local vshield A 192.168.199.40 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local DC2 A 192.168.201.4 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local VC2 A 192.168.201.5 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local Host11 A 192.168.201.11 >> C:\DNS.log
dnscmd localhost /RecordAdd lab.local Host12 A 192.168.201.12 >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 2 PTR GW.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 5 PTR VC.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 6 PTR VMA.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 7 PTR NAS.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 11 PTR Host1.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 12 PTR Host2.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 13 PTR Host3.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 14 PTR Host4.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 33 PTR cs1.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 34 PTR cs2.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 35 PTR SS.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 36 PTR V1.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 37 PTR VBR.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 38 PTR vcd.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 39 PTR vcd-proxy.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 199.168.192.in-addr.arpa 40 PTR vshield.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 201.168.192.in-addr.arpa 4 PTR DC2.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 201.168.192.in-addr.arpa 5 PTR VC2.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 201.168.192.in-addr.arpa 11 PTR Host11.lab.local >> C:\DNS.log
dnscmd localhost /RecordAdd 201.168.192.in-addr.arpa 12 PTR Host12.lab.local >> C:\DNS.log
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 "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") {
$vc6SQL = $true
Write-BuildLog "SQL Server 2012 Express SP1 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
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
Start-Process "C:\Program Files\Microsoft SQL Server\110\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDBvCD51.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
Start-Process "C:\Program Files\Microsoft SQL Server\110\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDBvCD15.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
regedit -s B:\Automate\DC\SQLTCP.reg
} elseif (Test-Path "B:\VIM_55\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") {
$vc5SQL = $true
Write-BuildLog "SQL Server 2008 R2 Express SP1 for vCenter 5.5 found; installing."
copy B:\VIM_55\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\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDB.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDBvCD51.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDBvCD15.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
regedit -s B:\Automate\DC\SQLTCP.reg
} elseif (Test-Path "B:\VIM_51\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") {
$vc5SQL = $true
Write-BuildLog "SQL Server 2008 R2 Express SP1 for vCenter 5.1 found; installing."
copy B:\VIM_51\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
Write-BuildLog "Creating Databases."
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDB.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDBvCD51.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDBvCD15.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
regedit -s B:\Automate\DC\SQLTCP.reg
} elseif (Test-Path "B:\VIM_50\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") {
$vc5SQL = $true
Write-BuildLog "SQL Server 2008 R2 Express SP1 for vCenter 5.0 found; installing."
copy B:\VIM_50\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
Write-BuildLog "Creating Databases."
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDB.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc\SQLEXPRESS -i B:\Automate\DC\MakeDBvCD15.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
regedit -s B:\Automate\DC\SQLTCP.reg
} elseif (Test-Path "B:\VIM_41\redist\SQLEXPR\x64\SQLEXPR.EXE") {
copy B:\VIM_41\redist\SQLEXPR\x64\SQLEXPR.EXE C:\temp
Write-BuildLog "SQL Server 2005 Express for vCenter 4.1 found; installing."
$Arguments = '/qb INSTANCENAME=SQLExpress ADDLOCAL=ALL SAPWD="VMware1!" SQLACCOUNT="Lab\vi-admin" SQLPASSWORD="' + $AdminPWD + '" AGTACCOUNT="Lab\vi-admin" AGTPASSWORD="' + $AdminPWD + '" SQLBROWSERACCOUNT="Lab\vi-admin" SQLBROWSERPASSWORD="' + $AdminPWD + '" DISABLENETWORKPROTOCOLS=0'
Start-Process C:\temp\SQLEXPR_x64_ENU.exe -ArgumentList $Arguments -Wait
Write-BuildLog "Creating Databases."
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 {
$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."
Read-Host "Press <ENTER> to exit"
exit
}
}
If (((([System.Environment]::OSVersion.Version.Major *10) +[System.Environment]::OSVersion.Version.Minor) -le 62)) {
if (Test-Path B:\sqlmsssetup.exe) {
Rename-Item B:\sqlmsssetup.exe SQLManagementStudio_x64_ENU.exe
}
if (Test-Path B:\SQLManagementStudio_x64_ENU.exe) {
if ( (!(Get-ChildItem B:\SQLManagementStudio_x64_ENU.exe).VersionInfo.ProductVersion -like "10.50.2500*") -and ($vc6SQL -or $vc5SQL -or $vc4SQL)) {
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."
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 2008"
Start-Process pkgmgr -ArgumentList '/quiet /l:C:\IIS_Install_Log.txt /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-CGI;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-ODBCLogging;IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;IIS-ClientCertificateMappingAuthentication;IIS-IISCertificateMappingAuthentication;IIS-URLAuthorization;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;IIS-FTPPublishingService;IIS-FTPServer;IIS-FTPManagement;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI' -Wait
Write-BuildLog "Setup Certificate Authority & web enrollment."
if (Test-Path B:\Automate\DC\setupca.vbs) {
copy B:\Automate\DC\setupca.vbs C:\temp
#Cscript C:\temp\setupca.vbs /ie /iw /sn LabCA /sk 4096 /sp "RSA#Microsoft Software Key Storage Provider" /sa SHA256 >> c:\SetupCA.log
Cscript C:\temp\setupca.vbs /ie /sn LabCA /sk 4096 /sp "RSA#Microsoft Software Key Storage Provider" /sa SHA256 >> c:\SetupCA.log
}
}
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 "Installing Administration tools."
Install-WindowsFeature Name RSAT-DHCP,RSAT-DNS-Server
Write-BuildLog "Setup IIS on Windows 2012"
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}
Import-Module WebAdministration
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
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
$Thumb = (dir cert:\localmachine\my | where {$_.Subject -eq "CN=LabCA"} | Select Thumbprint).Thumbprint
get-item cert:\localmachine\my\$Thumb | new-item IIS:\SslBindings\0.0.0.0!443
certutil -dsaddtemplate b:\automate\DC\VMware-SSL.txt
}
Write-BuildLog "Make Win32Time authoritative for NTP time."
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config /v AnnounceFlags /t REG_DWORD /d 0x05 /f
w32tm /config /manualpeerlist:pool.ntp.org /syncfromflags:manual /reliable:yes /update
Write-BuildLog "Clear System eventlog, erors to here are spurious"
Clear-EventLog -LogName System -confirm:$False
Write-BuildLog "Setup Default web page."
xcopy B:\Automate\DC\WWWRoot\*.* C:\inetpub\wwwroot\ /s /c /y /q
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
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."
tzutil /s "$timezone"
}
Write-BuildLog "Checking for VMware Tools..."
if (Test-Path -Path "B:\VMTools\setup*") {
Write-BuildLog "VMware Tools found."
$vmtools = $true
} else {
if (Test-Path "B:\VMTools\windows.iso") {
Write-BuildLog "Extracting VMware Tools from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VMtools\ B:\VMTools\windows.iso >> C:\ExtractLog.txt
$vmtools = $true
}
Else {
cd c:\temp
$vcinstall = ((Select-String -SimpleMatch "VCInstall=" -Path "B:\Automate\automate.ini").line).substring(10)
switch ($vcinstall) {
60 {
B:\Automate\_Common\wget.exe -nd http://packages.vmware.com/tools/esx/6.0/windows/VMware-tools-windows-9.10.0-2476743.iso -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."
} 55 {
B:\Automate\_Common\wget.exe -nd http://packages.vmware.com/tools/esx/5.5u2/windows/VMware-tools-windows-9.4.10-2068191.iso -awget.log
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VMtools\ c:\temp\VMware-tools-windows-9.4.10-2068191.iso >> C:\ExtractLog.txt
Write-BuildLog "VMware Tools V5.5u2 Downloaded and extracted to build share."
} 51 {
B:\Automate\_Common\wget.exe -nd http://packages.vmware.com/tools/esx/5.1u3/windows/x64/VMware-tools-windows-9.0.15-2323214.iso -awget.log
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VMtools\ c:\temp\VMware-tools-windows-9.0.15-2323214.iso >> C:\ExtractLog.txt
Write-BuildLog "VMware Tools V5.1u3 Downloaded and extracted to build share."
} 50 {
B:\Automate\_Common\wget.exe -nd http://packages.vmware.com/tools/esx/5.0u3/windows/x64/VMware-tools-windows-8.6.11-1310128.iso -awget.log
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VMtools\ c:\temp\VMware-tools-windows-8.6.11-1310128.iso >> C:\ExtractLog.txt
Write-BuildLog "VMware Tools V5.0u3 Downloaded and extracted to build share."
}
}
}
if (Test-Path -Path "B:\VMTools\setup*") {
Write-BuildLog "VMware Tools found."
$vmtools = $true
}
Write-BuildLog ""
}
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."
Start-Process B:\VMTools\setup64.exe -ArgumentList '/s /v "/qn"' -verb RunAs -Wait
Start-Sleep -Seconds 5
}
Read-Host "Press <ENTER> to exit"

Binary file not shown.

View File

@ -0,0 +1,525 @@
function Install-CertificationAuthority {
<#
.Synopsis
Installs Active Directory Certificate Services role on local computer.
.Description
Installs Active Directory Certificate Services (AD CS) role on local computer. A user can choose different options, such
Certification Authority (CA) type, key pair parameters, CA certificate validity and so on.
The command supports Windows Server 2008 R2 Server Core installations.
.Parameter CAName
Specifies a custom CA certificate name/subject (what you see in the certificate display UI). If not passed, a '<ComputerName>-CA'
form is used for workgroup CAs and '<DomainName>-<ComputerName-CA>' form is used for domain CAs. The parameter supports Unicode names.
.Parameter CADNSuffix
Specifies a DN suffix to specify some additional information. For example, company name, country, city, etc. DN suffix is empty for
workgroup CAs and includes current domain distinguished name (for example, DC=domain,DC=com). The parameter accepts suffixes in a
X500 form, for example: OU=Information Systems, O=Sysadmins LV, C=LV.
.Parameter CAType
Specifies CA type:
Standalone Root,
Standalone Subordinate,
Enterprise Root,
Enterprise Subordinate.
If not passed, for non-domain environments or if you don't have Enterprise Admins rights, Standalone Root is used. If you have
Enterprise Admins rights and your forest already has installed CAs, Enterprise Subordinate is used. If no Enterprise CAs installed
in the forest, Enterprise Root is used.
.Parameter ParentCA
This parameter allows you to specify parent CA location only if you install Enterprise Subordinate CA. For other CA types, the
parameter is ignored. Parent CA information must be passed in the following form: CAComputerName\CASanitizedName. Sanitized name
is a sanitized form of CA name (subject). Mostly sanitized name is the same as CA name (unless you use Unicode and/or special
characters, that are disallowed in X500). If the parameter is not specified, a certificate request will be generated on the root
of system drive. I've decided to not implement this parameter for Standalone Subordinate CAs, because mostly they are installed
in a workgroup environments and direct request submission to other CAs is likely unavailable (due of computer authentication
complexity in the non-domain environments). However, if you need it contact me.
.Parameter CSP
Specifies custom cryptographic service provider. By default 'RSA#Microsoft Software Key Storage Provider' is used (in most cases
you will use default CSP). You need to explicitly specify custom CSP only when you setup completely CNG authority (CSPs with ECDSA
prefix) or you use HSM. Each HSM uses it's own custom CSP. You must install HSM middleware before CA installation.
The full list of supportable and available "by default" CSPs for Windows Server 2008+ is:
Microsoft Base Cryptographic Provider v1.0
Microsoft Base DSS Cryptographic Provider
Microsoft Base Smart Card Crypto Provider
Microsoft Enhanced Cryptographic Provider v1.0
Microsoft Strong Cryptographic Provider
RSA#Microsoft Software Key Storage Provider
DSA#Microsoft Software Key Storage Provider
ECDSA_P256#Microsoft Software Key Storage Provider
ECDSA_P384#Microsoft Software Key Storage Provider
ECDSA_P521#Microsoft Software Key Storage Provider
RSA#Microsoft Smart Card Key Storage Provider
ECDSA_P256#Microsoft Smart Card Key Storage Provider
ECDSA_P384#Microsoft Smart Card Key Storage Provider
ECDSA_P521#Microsoft Smart Card Key Storage Provider
.Parameter KeyLength
This parameter specifies the key length. If not specified, a 2048-bit key will be generated. There is a little trick: if you look to
a CSP list (above), you will see that key length is specified for each ECDSA* provider. I've developed a script logic in that way,
so the script ignores this parameter if one of ECDSA* CSP is explicitly chosen and uses key length that is supported by the CSP.
Therefore you will not receive an error if you select 'ECDSA_P256#Microsoft Smart Card Key Storage Provider' CSP with 2048 key length.
256-bit key will be selected automatically
.Parameter HashAlgorithm
This parameter specifies hash algorithm that will be used for CA certificate/request hashing. Note that this is important for root
CA installations. Subordinate CA certificates are hashed and signed by the parent CA with it's own settings. By default 'SHA1' is
used (though this parameter is applicable for all CA installation types).
.Parameter ValidForYears
Specifies the validity for root CA installations. By default root CA certificates are valid for 5 years. You can increase this value
to 10, 20, 50, whatever you need. For any subordinate CA types this parameter is silently ignored. This is because subordinate CA
validity is determined by the parent CA. This parameter accepts integer values, assuming that the value is specified in years.
.Parameter RequestFileName
If you setup any sort of subordinate (not root) CAs you can specify custom path to a request file. By default request file is
generated on the root of system drive.
.Parameter CACertFile
Specifies the path to a PFX file with CA certificate. Relative paths are allowed. Setup API performs additional checks for the certificate.
Therefore you must ensure if: this is CA certificate (but not EFS encryption ;)), CA certificate is trusted (for non-root certificates)
and chains to trusted CA and CA certificate revocation checking can be performed. Otherwise you will unable to setup CA with that CA certificate.
.Parameter Password
Specifies the password to open PFX file. The parameter supports only securestrings! You can't type a password as a simple text. This is made for
security reasons. There are few ways to pass a password in a securestring form:
$Password = Read-Host a
or
ConvertTo-SecureString <plaintext> a f
You can enclose last command in parentheses and pass directly as a parameter value.
.Parameter Thumbprint
specifies a thumbprint of the certificate to use. The certificate must be installed in Local Machine\Personal store and must be trusted
(for non-root certificates) and must not be revoked (the issuer revocation information must be available).
.Parameter DBDirectory
Specifies the path to a folder to store CA database. If not specified, the default path: %windir%\System32\CertLog folder is used. If you
need to specify custom path (for example, shared storage for CA clusters), you need to specify the next parameter too. The path must be valid.
.Parameter LogDirectory
Specifies the path to a folderto store CA database log files. By default %windir%\System32\CertLog folder is used. If you use custom path for
either database or log folders, you must explicitly specify both paths.
.Parameter OverwriteExisting
Specifies, whether to overwrite any existing database files in the specified directories.
.Parameter AllowCSPInteraction
Specifies, whether the cryptographic service provider (CSP) is allowed to interact with the desktop. This parameter should be used only if you
use custom hardware-based CSP (HSM or smart card CSP). In other cases you don't need to allow CSP interactions.
.Parameter Force
By default, the script explicitly prompts you whether you want to install Certification Authority with selected values. If you want to implement
silent (quiet) installations specify this parameter to suppress any prompts during role installation
.EXAMPLE
PS > Install-CertificationAuthority -CAName "My Root CA" -CADNSuffix "OU=Information Systems, O=Sysadmins LV, C=LV" `
-CAType "Standalone Root" -ValidForYears 10
In this scenario you setup new Standalone Root CA with "CN=My Root CA, OU=Information Systems, O=Sysadmins LV, C=LV" subject, that will be valid
for 10 years. The CA will use default paths to CA database and log files and certificate will use 'RSA#Microsoft Software Key Storage Provider'
CSP with 2048-bit key and SHA1 hashing algorithm.
.EXAMPLE
PS > Install-CertificationAuthority -CAName "My Root CA" -CADNSuffix "OU=Information Systems, O=Sysadmins LV, C=LV" `
-CAType "Standalone Root" -ValidForYears 20 -CSP "ECDSA_P256#Microsoft Smart Card Key Storage Provider" `
-HashAlgorithm SHA512
This example is similar to previous, with the exception that this CA will be completely CNG/SHA2 root. CA certificate will use CNG (not RSA)
keys and hashing algorithm will be SHA512.
.EXAMPLE
PS > Install-CertificationAuthority -CAName "Clustered CA" -CADNSuffix "OU=Information Systems, O=Sysadmins LV, C=LV" `
-CAType "Enterprise Subordinate" -KeyLength 4096 -DBDirectory "S:\CertDB" -LogDirectory "S:\CertLog" `
-RequestFileName "S:\Clustered CA.req"
This example assumes that you setup CA cluster first node (but not necessary). CA database will be stored on a shared storage (attached with S: drive letter).
CA certificate will use default 'RSA#Microsoft Software Key Storage Provider' with 4096-bit key and default SHA1 hashing algorithm. CA certificate validity
will be determined by the parent CA. In addition, CA certificate request will be stored on the shared storage.
.EXAMPLE
PS > $Password = Read-Host -AsSecureString
PS > Install-CertificationAuthority -CACertFile .\ClusteredCA.pfx -Password $Password `
-DBDirectory "S:\CertDB" -LogDirectory "S:\CertLog" -OverwriteExisting
This is two-line example. Say, you have successfully installed CA cluster first node and have exported CA certificate to a PFX, and moved it to the second
node (to the current directory). At first you will be prompted for a password. Since you type password to a securestring prompt, no characters will be displayed.
After that you will specify relative path to a PFX file and specify shared storage to store CA database and log files. You overwrite database files that was
created during first node installation. Actually this command installs CA cluster second node.
.EXAMPLE
PS > Install-CertificationAuthority -CAName "Company Enterprise CA-2" -CADNSuffix "O=Company, E=companypky@company.com" `
-CAType "Enterprise Subordinate" -ParentCA "ca01.company.com\Company Enterprise CA-1"
From best-practices perspective this is not a very good example, because it assumes at least 2 tiers of Enterprise CAs. However, it is still common. In a given
example, Enterprise Subordinate CA will be installed and certificate request will be sent directly to existing Enterprise CA 'Company Enterprise CA-1' that is
hosted on 'ca01.company.com'. Note that existing CA must be online and must issue 'Subordinate Certification Authority' template.
.Inputs
None.
.Outputs
None.
.NOTES
Author: Vadims Podans
Blog : http://en-us.sysadmins.lv
#>
[CmdletBinding(
DefaultParameterSetName = 'NewKeySet',
ConfirmImpact = 'High',
SupportsShouldProcess = $true
)]
param(
[Parameter(ParameterSetName = 'NewKeySet')]
[string]$CAName,
[Parameter(ParameterSetName = 'NewKeySet')]
[string]$CADNSuffix,
[Parameter(ParameterSetName = 'NewKeySet')]
[ValidateSet("Standalone Root","Standalone Subordinate","Enterprise Root","Enterprise Subordinate")]
[string]$CAType,
[Parameter(ParameterSetName = 'NewKeySet')]
[string]$ParentCA,
[Parameter(ParameterSetName = 'NewKeySet')]
[string]$CSP,
[Parameter(ParameterSetName = 'NewKeySet')]
[int]$KeyLength,
[Parameter(ParameterSetName = 'NewKeySet')]
[string]$HashAlgorithm,
[Parameter(ParameterSetName = 'NewKeySet')]
[int]$ValidForYears = 5,
[Parameter(ParameterSetName = 'NewKeySet')]
[string]$RequestFileName,
[Parameter(Mandatory = $true, ParameterSetName = 'PFXKeySet')]
[IO.FileInfo]$CACertFile,
[Parameter(Mandatory = $true, ParameterSetName = 'PFXKeySet')]
[Security.SecureString]$Password,
[Parameter(Mandatory = $true, ParameterSetName = 'ExistingKeySet')]
[string]$Thumbprint,
[string]$DBDirectory,
[string]$LogDirectory,
[switch]$OverwriteExisting,
[switch]$AllowCSPInteraction,
[switch]$Force
)
#region OS and existing CA checking
# check if script running on Windows Server 2008 or Windows Server 2008 R2
$OS = Get-WmiObject Win32_OperatingSystem -Property ProductType
if ([Environment]::OSVersion.Version.Major -lt 6) {
Write-Error -Category NotImplemented -ErrorId "NotSupportedException" `
-Message "Windows XP, Windows Server 2003 and Windows Server 2003 R2 are not supported!"
return
}
if ($OS.ProductType -eq 1) {
Write-Error -Category NotImplemented -ErrorId "NotSupportedException" `
-Message "Client operating systems are not supported!"
return
}
$CertConfig = New-Object -ComObject CertificateAuthority.Config
try {$ExistingDetected = $CertConfig.GetConfig(3)}
catch {}
if ($ExistingDetected) {
Write-Error -Category ResourceExists -ErrorId "ResourceExistsException" `
-Message "Certificate Services are already installed on this computer. Only one Certification Authority instance per computer is supported."
return
}
#endregion
#region Binaries checking and installation if necessary
if ([Environment]::OSVersion.Version.Major -eq 6 -and [Environment]::OSVersion.Version.Minor -eq 0) {
cmd /c "servermanagercmd -install AD-Certificate 2> null" | Out-Null
} else {
try {Import-Module ServerManager -ErrorAction Stop}
catch {
ocsetup 'ServerManager-PSH-Cmdlets' /quiet | Out-Null
Start-Sleep 1
Import-Module ServerManager -ErrorAction Stop
}
$status = (Get-WindowsFeature -Name AD-Certificate).Installed
# if still no, install binaries, otherwise do nothing
if (!$status) {$retn = Add-WindowsFeature -Name AD-Certificate -ErrorAction Stop
if (!$retn.Success) {
Write-Error -Category NotInstalled -ErrorId "NotInstalledException" `
-Message "Unable to install ADCS installation packages due of the following error: $($retn.breakCode)"
return
}
}
}
try {$CASetup = New-Object -ComObject CertOCM.CertSrvSetup.1}
catch {
Write-Error -Category NotImplemented -ErrorId "NotImplementedException" `
-Message "Unable to load necessary interfaces. Your Windows Server operating system is not supported!"
return
}
# initialize setup binaries
try {$CASetup.InitializeDefaults($true, $false)}
catch {
Write-Error -Category InvalidArgument -ErrorId ParameterIncorrectException `
-ErrorAction Stop -Message "Cannot initialize setup binaries!"
}
#endregion
#region Property enums
$CATypesByName = @{"Enterprise Root" = 0; "Enterprise Subordinate" = 1; "Standalone Root" = 3; "Standalone Subordinate" = 4}
$CATypesByVal = @{}
$CATypesByName.keys | ForEach-Object {$CATypesByVal.Add($CATypesByName[$_],$_)}
$CAPRopertyByName = @{"CAType"=0;"CAKeyInfo"=1;"Interactive"=2;"ValidityPeriodUnits"=5;
"ValidityPeriod"=6;"ExpirationDate"=7;"PreserveDataBase"=8;"DBDirectory"=9;"Logdirectory"=10;
"ParentCAMachine"=12;"ParentCAName"=13;"RequestFile"=14;"WebCAMachine"=15;"WebCAName"=16
}
$CAPRopertyByVal = @{}
$CAPRopertyByName.keys | ForEach-Object {$CAPRopertyByVal.Add($CAPRopertyByName[$_],$_)}
$ValidityUnitsByName = @{"years" = 6}
$ValidityUnitsByVal = @{6 = "years"}
#endregion
$ofs = ", "
#region Key set processing functions
#region NewKeySet
function NewKeySet ($CAName, $CADNSuffix, $CAType, $ParentCA, $CSP, $KeyLength, $HashAlgorithm, $ValidForYears, $RequestFileName) {
#region CSP, key length and hashing algorithm verification
$CAKey = $CASetup.GetCASetupProperty(1)
if ($CSP -ne "") {
if ($CASetup.GetProviderNameList() -notcontains $CSP) {
# TODO add available CSP list
Write-Error -Category InvalidArgument -ErrorId "InvalidCryptographicServiceProviderException" `
-ErrorAction Stop -Message "Specified CSP '$CSP' is not valid!"
} else {
$CAKey.ProviderName = $CSP
}
} else {
$CAKey.ProviderName = "RSA#Microsoft Software Key Storage Provider"
}
if ($KeyLength -ne 0) {
if ($CASetup.GetKeyLengthList($CSP).Length -eq 1) {
$CAKey.Length = $CASetup.GetKeyLengthList($CSP)[0]
} else {
if ($CASetup.GetKeyLengthList($CSP) -notcontains $KeyLength) {
Write-Error -Category InvalidArgument -ErrorId "InvalidKeyLengthException" `
-ErrorAction Stop -Message @"
The specified key length '$KeyLength' is not supported by the selected CSP '$CSP' The following
key lengths are supported by this CSP: $($CASetup.GetKeyLengthList($CSP))
"@
}
$CAKey.Length = $KeyLength
}
}
if ($HashAlgorithm -ne "") {
if ($CASetup.GetHashAlgorithmList($CSP) -notcontains $HashAlgorithm) {
Write-Error -Category InvalidArgument -ErrorId "InvalidHashAlgorithmException" `
-ErrorAction Stop -Message @"
The specified hash algorithm is not supported by the selected CSP '$CSP' The following
hash algorithms are supported by this CSP: $($CASetup.GetHashAlgorithmList($CSP))
"@
}
$CAKey.HashAlgorithm = $HashAlgorithm
}
$CASetup.SetCASetupProperty(1,$CAKey)
#endregion
#region Setting CA type
if ($CAType) {
$SupportedTypes = $CASetup.GetSupportedCATypes()
$SelectedType = $CATypesByName[$CAType]
if ($SupportedTypes -notcontains $CATypesByName[$CAType]) {
Write-Error -Category InvalidArgument -ErrorId "InvalidCATypeException" `
-ErrorAction Stop -Message @"
Selected CA type: '$CAType' is not supported by current Windows Server installation.
The following CA types are supported by this installation: $([int[]]$CASetup.GetSupportedCATypes() | %{$CATypesByVal[$_]})
"@
} else {$CASetup.SetCASetupProperty($CAPRopertyByName.CAType,$SelectedType)}
}
#endregion
#region setting CA certificate validity
if ($SelectedType -eq 0 -or $SelectedType -eq 3 -and $ValidForYears -ne 0) {
try{$CASetup.SetCASetupProperty(6,$ValidForYears)}
catch {
Write-Error -Category InvalidArgument -ErrorId "InvalidCAValidityException" `
-ErrorAction Stop -Message "The specified CA certificate validity period '$ValidForYears' is invalid."
}
}
#endregion
#region setting CA name
if ($CAName -ne "") {
if ($CADNSuffix -ne "") {$Subject = "CN=$CAName" + ",$CADNSuffix"} else {$Subject = "CN=$CAName"}
$DN = New-Object -ComObject X509Enrollment.CX500DistinguishedName
# validate X500 name format
try {$DN.Encode($Subject,0x0)}
catch {
Write-Error -Category InvalidArgument -ErrorId "InvalidX500NameException" `
-ErrorAction Stop -Message "Specified CA name or CA name suffix is not correct X.500 Distinguished Name."
}
$CASetup.SetCADistinguishedName($Subject, $true, $true, $true)
}
#endregion
#region set parent CA/request file properties
if ($CASetup.GetCASetupProperty(0) -eq 1 -and $ParentCA) {
[void]($ParentCA -match "^(.+)\\(.+)$")
try {$CASetup.SetParentCAInformation($ParentCA)}
catch {
Write-Error -Category ObjectNotFound -ErrorId "ObjectNotFoundException" `
-ErrorAction Stop -Message @"
The specified parent CA information '$ParentCA' is incorrect. Make sure if parent CA
information is correct (you must specify existing CA) and is supplied in a 'CAComputerName\CASanitizedName' form.
"@
}
} elseif ($CASetup.GetCASetupProperty(0) -eq 1 -or $CASetup.GetCASetupProperty(0) -eq 4 -and $RequestFileName -ne "") {
$CASetup.SetCASetupProperty(14,$RequestFileName)
}
#endregion
}
#endregion
#region PFXKeySet
function PFXKeySet ($CACertFile, $Password) {
$FilePath = Resolve-Path $CACertFile -ErrorAction Stop
try {[void]$CASetup.CAImportPFX(
$FilePath.Path,
[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($Password)),
$true)
} catch {Write-Error $_ -ErrorAction Stop}
}
#endregion
#region ExistingKeySet
function ExistingKeySet ($Thumbprint) {
$ExKeys = $CASetup.GetExistingCACertificates() | ?{
([Security.Cryptography.X509Certificates.X509Certificate2]$_.ExistingCACertificate).Thumbprint -eq $Thumbprint
}
if (!$ExKeys) {
Write-Error -Category ObjectNotFound -ErrorId "ElementNotFoundException" `
-ErrorAction Stop -Message "The system cannot find a valid CA certificate with thumbprint: $Thumbprint"
} else {$CASetup.SetCASetupProperty(1,@($ExKeys)[0])}
}
#endregion
#endregion
#region set database settings
if ($DBDirectory -ne "" -and $LogDirectory -ne "") {
try {$CASetup.SetDatabaseInformation($DBDirectory,$LogDirectory,$null,$OverwriteExisting)}
catch {
Write-Error -Category InvalidArgument -ErrorId "InvalidPathException" `
-ErrorAction Stop -Message "Specified path to either database directory or log directory is invalid."
}
} elseif ($DBDirectory -ne "" -and $LogDirectory -eq "") {
Write-Error -Category InvalidArgument -ErrorId "InvalidPathException" `
-ErrorAction Stop -Message "CA Log file directory cannot be empty."
} elseif ($DBDirectory -eq "" -and $LogDirectory -ne "") {
Write-Error -Category InvalidArgument -ErrorId "InvalidPathException" `
-ErrorAction Stop -Message "CA database directory cannot be empty."
}
#endregion
# process parametersets.
switch ($PSCmdlet.ParameterSetName) {
"ExistingKeySet" {ExistingKeySet $Thumbprint}
"PFXKeySet" {PFXKeySet $CACertFile $Password}
"NewKeySet" {NewKeySet $CAName $CADNSuffix $CAType $ParentCA $CSP $KeyLength $HashAlgorithm $ValidForYears $RequestFileName}
}
try {
Write-Host "Installing Certification Authority role on $env:computername ..." -ForegroundColor Cyan
if ($Force -or $PSCmdlet.ShouldProcess($env:COMPUTERNAME, "Install Certification Authority")) {
$CASetup.Install()
$PostRequiredMsg = @"
Certification Authority role was successfully installed, but not completed. To complete installation submit
request file '$($CASetup.GetCASetupProperty(14))' to parent Certification Authority
and install issued certificate by running the following command: certutil -installcert 'PathToACertFile'
"@
if ($CASetup.GetCASetupProperty(0) -eq 1 -and $ParentCA -eq "") {
Write-Host $PostRequiredMsg -ForegroundColor Yellow -BackgroundColor Black
} elseif ($CASetup.GetCASetupProperty(0) -eq 1 -and $PSCmdlet.ParameterSetName -eq "NewKeySet" -and $ParentCA -ne "") {
$CASName = (Get-ItemProperty HKLM:\System\CurrentControlSet\Services\CertSvc\Configuration).Active
$SetupStatus = (Get-ItemProperty HKLM:\System\CurrentControlSet\Services\CertSvc\Configuration\$CASName).SetupStatus
$RequestID = (Get-ItemProperty HKLM:\System\CurrentControlSet\Services\CertSvc\Configuration\$CASName).RequestID
if ($SetupStatus -ne 1) {
Write-Host $PostRequiredMsg -ForegroundColor Yellow -BackgroundColor Black
}
} elseif ($CASetup.GetCASetupProperty(0) -eq 4) {
Write-Host $PostRequiredMsg -ForegroundColor Yellow -BackgroundColor Black
} else {Write-Host "Certification Authority role is successfully installed!" -ForegroundColor Green}
}
} catch {Write-Error $_ -ErrorAction Stop}
Remove-Module ServerManager -ErrorAction SilentlyContinue
}
function Uninstall-CertificationAuthority {
<#
.Synopsis
Uninstalls Active Directory Certificate Services role from the local computer.
.Description
Uninstalls Active Directory Certificate Services role from the local computer.
The command supports Windows Server 2008 R2 Server Core installations.
.Parameter AutoRestart
Automatically restarts computer to complete CA role removal. Otherwise you will have to restart the server manually.
.Parameter Force
By default, the commands prompts you whether you want to remove CA role. Use Force switch to suppress all prompts.
.EXAMPLE
PS > Uninstall-CertificationAuthority -AutoRestart -Force
The command will uninstall CA role, suppresses all prompts and automatically restarts the server upon completion.
.Inputs
None.
.Outputs
None.
.NOTES
Author: Vadims Podans
Blog : http://en-us.sysadmins.lv
#>
[CmdletBinding(
ConfirmImpact = 'High',
SupportsShouldProcess = $true
)]
param(
[switch]$AutoRestart,
[switch]$Force
)
#region OS and existing CA checking
# check if script running on Windows Server 2008 or Windows Server 2008 R2
$OS = Get-WmiObject Win32_OperatingSystem -Property ProductType
if ([Environment]::OSVersion.Version.Major -lt 6) {
Write-Error -Category NotImplemented -ErrorId "NotSupportedException" `
-Message "Windows XP, Windows Server 2003 and Windows Server 2003 R2 are not supported!"
return
}
if ($OS.ProductType -eq 1) {
Write-Error -Category NotImplemented -ErrorId "NotSupportedException" `
-Message "Client operating systems are not supported!"
return
}
$CertConfig = New-Object -ComObject CertificateAuthority.Config
try {$ExistingDetected = $CertConfig.GetConfig(3)}
catch {
Write-Error -Category ObjectNotFound -ErrorId "ElementNotFoundException" `
-ErrorAction Stop -Message "Certificate Services are not installed on this computer."
}
#endregion
#region Binaries checking and removal stuff
try {$CASetup = New-Object -ComObject CertOCM.CertSrvSetup.1}
catch {
Write-Error -Category NotImplemented -ErrorId "NotImplementedException" `
-Message "Unable to load necessary interfaces. Your Windows Server operating system is not supported!"
return
}
if ([Environment]::OSVersion.Version.Major -eq 6 -and [Environment]::OSVersion.Version.Minor -eq 0) {
cmd /c "servermanagercmd -remove ADCS-Cert-Authority 2> null" | Out-Null
} else {
try {Import-Module ServerManager -ErrorAction Stop}
catch {
ocsetup 'ServerManager-PSH-Cmdlets' /quiet | Out-Null
Start-Sleep 2
Import-Module ServerManager
}
$status = (Get-WindowsFeature -Name ADCS-Cert-Authority).Installed
if ($status) {
$WarningPreference = "SilentlyContinue"
if ($Force -or $PSCmdlet.ShouldProcess($env:COMPUTERNAME, "Uninstall Certification Authority")) {
$CASetup.PreUninstall($false)
$retn = Remove-WindowsFeature -Name ADCS-Cert-Authority -ErrorAction Stop
}
}
}
if ($AutoRestart) {
#Restart-Computer -Force
} else {
Write-Host "Certification Authority role was removed successfully. You must restart this server to complete role removal." `
-ForegroundColor Yellow -BackgroundColor Black
}
#endregion
}

View File

@ -0,0 +1,14 @@
set WshShell = WScript.CreateObject("WScript.Shell")
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\BuildLog.lnk")
oShortCutLink.TargetPath = "c:\BuildLog.txt"
oShortCutLink.Save
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\Validate.lnk")
oShortCutLink.TargetPath = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"
oShortCutLink.Arguments = " c:\validate.ps1"
oShortCutLink.Save
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\Upgrade.lnk")
oShortCutLink.TargetPath = "\\nas\Build\Automate\DC\Upgrade.cmd"
oShortCutLink.Save

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,7 @@
ENU TITLE ESX 4.1 installs
LABEL Main Menu
MENU LABEL ^Return to Main Menu
KERNEL pxelinux.cfg/menu.c32
APPEND pxelinux.cfg/default

View File

@ -0,0 +1,23 @@
MENU TITLE ESXi 5.0 installs
LABEL Main Menu
MENU LABEL ^Return to Main Menu
KERNEL pxelinux.cfg/menu.c32
APPEND pxelinux.cfg/default
label esx50
KERNEL /esxi50/mboot.c32
APPEND -c /esxi50/boot.cfg
MENU LABEL ESXi 5.0 Manual Install
label esx1-5
KERNEL /esxi50/mboot.c32
APPEND -c /esxi50/Besx1-5.cfg
MENU LABEL Host1 Automated Install
Label ESX2-5
KERNEL /esxi50/mboot.c32
APPEND -c /esxi50/Besx2-5.cfg
MENU LABEL Host2 Automated Install

View File

@ -0,0 +1,27 @@
MENU TITLE ESXi 5.1 installs
LABEL Main Menu
MENU LABEL ^Return to Main Menu
KERNEL pxelinux.cfg/menu.c32
APPEND pxelinux.cfg/default
label esx51
KERNEL /esxi51/mboot.c32
APPEND -c /esxi51/boot.cfg
MENU LABEL ESXi 5.1 Manual Install
label ESX1-5
KERNEL /esxi51/mboot.c32
APPEND -c /esxi51/Besx1-5.cfg
MENU LABEL Host1 Automated Install
Label ESX2-5
KERNEL /esxi51/mboot.c32
APPEND -c /esxi51/Besx2-5.cfg
MENU LABEL Host2 Automated Install
Label ESX3-5
KERNEL /esxi51/mboot.c32
APPEND -c /esxi51/Besx3-5.cfg
MENU LABEL Host3 Automated Install

View File

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

View File

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

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,23 @@
menu title AutoLab PXE Menu
menu tabmsgrow 22
menu cmdlinerow 22
menu endrow 24
menu color title 1;34;49 #eea0a0ff #cc333355 std
menu color sel 7;37;40 #ff000000 #bb9999aa all
menu color border 30;44 #ffffffff #00000000 std
menu color pwdheader 31;47 #eeff1010 #20ffffff std
menu color hotkey 35;40 #90ffff00 #00000000 std
menu color hotsel 35;40 #90000000 #bb9999aa all
menu color timeout_msg 35;40 #90ffffff #00000000 none
menu color timeout 31;47 #eeff1010 #00000000 none
prompt 0
noescape 1
timeout 300
default pxelinux.cfg/menu.c32
label localboot
menu label Boot local hard disk
kernel pxelinux.cfg/chain.c32
append hd0 0

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,6 @@
MENU TITLE vCloud installs
LABEL Main Menu
MENU LABEL ^Return to Main Menu
KERNEL pxelinux.cfg/vesamenu.c32
APPEND pxelinux.cfg/default

View File

@ -0,0 +1,2 @@
F INITRD.IMG;1 initrd.img
F VMLINUZ.;1 vmlinuz

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
TFTPD32 is copyrighted 1998-2011 by Philippe Jounin (philippe@jounin.net) and released under the European Union Public License (see file EUPL-EN.pdf).

Binary file not shown.

View File

@ -0,0 +1,37 @@
[DHCP]
Lease_NumLeases=0
[TFTPD32]
BaseDirectory=C:\TFTP-Root
TftpPort=69
Hide=0
WinSize=0
Negociate=1
PXECompatibility=0
DirText=0
ShowProgressBar=1
Timeout=3
MaxRetransmit=6
SecurityLevel=1
UnixStrings=1
Beep=0
VirtualRoot=0
MD5=0
LocalIP=
Services=1
TftpLogFile=
SaveSyslogFile=
PipeSyslogMsg=0
LowestUDPPort=0
HighestUDPPort=0
MulticastPort=0
MulticastAddress=
PersistantLeases=1
DHCP Ping=1
DHCP LocalIP=
Max Simultaneous Transfers=100
UseEventLog=0
Console Password=tftpd32
Support for port Option=0
Keep transfer Gui=5
Ignore ack for last TFTP packet=0
Enable IPv6=0

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,23 @@
@echo off
cls
echo *
echo * Resetting and upgrading DC configuration
echo * This is a best effort script, there will be error messages and warnings
echo *
echo * VC will require a rebuild
echo *
echo * This script must be "Run as Administrator"
echo *
pause
echo * Running AutoLab Upgrade/Reset script >> c:\buildlog.txt
if exist C:\validate.ps1 del c:\validate.ps1
if exist C:\PSFunctions.ps1 del c:\PSFunctions.ps1
if exist C:\PXEMenuConfig.ps1 del c:\PXEMenuConfig.ps1
if exist C:\phase2.ps1 del c:\phase2.ps1
net use B: \\192.168.199.7\Build
copy B:\Automate\validate.ps1 C:\
copy B:\Automate\PSFunctions.ps1 C:\
copy B:\Automate\PXEMenuConfig.ps1 C:\
copy B:\Automate\DC\Phase2.ps1 C:\
powershell c:\Phase2.ps1
if exist C:\phase2.ps1 del c:\phase2.ps1

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,54 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type"><title>AutoLab Portal</title></head>
<body>
<h1>AutoLab Portal</h1>
<br>
<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2">
<tbody>
<tr>
<td colspan="2" rowspan="1"><h2 style="text-align: center;"><span style="font-weight: bold;">AutoLab management</span></h2></td>
</tr>
<tr>
<td>
<a href="https://vc.lab.local:9443/vsphere-client" target="_blank"><img style="border: 0px solid" alt="vSphere Web Client" title="vSphere Web Client" src="WebClient.png"><br> vSphere Web Client</a>
</td>
<td>
<a href="http://vcd.lab.local" target="_blank"><img style="border: 0px solid" alt="vCloud Director Management" title="vCloud Director Management" src="VCD.png"><br> vCloud Director Management</a> <br><a href="https://vshield.lab.local" target="_blank"> vShield Management</a>
</td>
</tr>
<tr>
<td>
<a href="http://www.freesco.org/"><img style="border: 0px solid ; width: 197px; height: 80px;" alt="FreeSCO Project" title="FreeSCO Project" src="FreeSCO.jpg"></a><a href="http://192.168.199.2:82"><br> Router Admin</a>
</td>
<td>
<a href="http://www.freenas.com"><img style="border: 0px solid ; width: 161px; height: 132px;" alt="FreeNAS" title="FreeNAS" src="FreeNAS.jpg"></a><a href="http://192.168.199.7"><br>NAS Admin</a>
</td>
</tr>
<tr>
<td><h2 style="text-align: center;"><a href="www.veeam.com" target="_blank">Veeam</a></h2>
</td>
<td><h2 style="text-align: center;">VMware View</h2>
</td>
</tr>
<tr>
<td><a href="http://v1.lab.local:1340"><img style="border: 0px solid ; width: 48px; height: 51px;" alt="Business View" title="Business View" src="BusinessView.jpg"></a> <a href="http://v1.lab.local:1340" target="_blank">Veeam
Business View</a><br>
<br>
<a href="http://v1.lab.local:1239/"><img style="border: 0px solid ; width: 47px; height: 51px;" alt="Veeam Reporter" title="Veeam Reporter" src="Reporter.jpg"></a> <a href="http://v1.lab.local:1239/" target="_blank">Veeam
ONE Reporter</a></td>
<td><a href="https://cs1.lab.local/admin"><img style="border: 0px solid ; width: 49px; height: 52px;" alt="View Administrator Portal" title="View Administrator Portal" src="VMView.jpg"></a>&nbsp;<a href="https://cs1.lab.local/admin" target="_blank">View
Administrator Console - CS1</a><br>
<br>
<a href="https://cs1.lab.local/"><img style="border: 0px solid ; width: 49px; height: 52px;" alt="VMware View Portal" title="VMware View Portal" src="VMView.jpg"></a> <a href="https://cs1.lab.local/" target="_blank">View
Portal - CS1</a><br>
</td>
</tr>
<tr>
<td><a href="http://192.168.199.254/WANem/"> WANem managemnet </a>
</td><td></td>
</tr>
</table>
<br>
</body></html>

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
$null = Add-WindowsFeature -name ad-domain-services -IncludeManagementTools
$AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9)
$safemodeadminpwd = ConvertTo-SecureString -String $AdminPWD -asplaintext -force
$Cred = New-Object System.Management.Automation.PsCredential "lab\administrator", $safemodeadminpwd
Write-Host "Add to domain"
Add-Computer -DomainName "Lab.local" -Credential $Cred
Write-Host "Promote to domain controller"
Install-ADDSDomainController

View File

@ -0,0 +1,11 @@
[DCInstall]
UserName=administrator
UserDomain=lab.local
Password=VMware1!
SiteName = "Lab"
ReplicaOrNewDomain=replica
ReplicaDomainDNSName=lab.local
InstallDNS=yes
ConfirmGC=yes
RebootOnCompletion=yes
SafeModeAdminPassword="VMware1!"

View File

@ -0,0 +1,8 @@
drop database vCenter
go
drop database SRM
go
drop database SRMRep
go
drop database RSA
go

View File

@ -0,0 +1,61 @@
Create Login vpx WITH PASSWORD = 'VMware1!'
Go
create Database vCenter
Go
ALTER AUTHORIZATION ON DATABASE::vCenter TO vpx
ALTER AUTHORIZATION ON DATABASE::msdb TO vpx
Go
Create Login VMSRM WITH PASSWORD = 'VMware1!'
Go
create database SRM
GO
create database SRMRep
GO
ALTER AUTHORIZATION ON DATABASE::SRM TO VMSRM
ALTER AUTHORIZATION ON DATABASE::SRMRep TO VMSRM
Go
EXEC master..sp_addsrvrolemember @loginame = 'lab\VI-admin', @rolename = 'sysadmin'
Go
EXEC master..sp_addsrvrolemember @loginame = 'lab\SVC_Veeam', @rolename = 'sysadmin'
Go
USE MASTER
GO
CREATE DATABASE RSA ON PRIMARY(
NAME='RSA_DATA',
FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\RSA_DATA.mdf',
SIZE=10MB,
MAXSIZE=UNLIMITED,
FILEGROWTH=10%),
FILEGROUP RSA_INDEX(
NAME='RSA_INDEX',
FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\RSA_INDEX.ndf',
SIZE=10MB,
MAXSIZE=UNLIMITED,
FILEGROWTH=10%)
LOG ON(
NAME='translog',
FILENAME='C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQLEXPRESS\MSSQL\DATA\translog.ldf',
SIZE=10MB,
MAXSIZE=UNLIMITED,
FILEGROWTH=10% )
GO
SP_DBOPTION 'RSA', 'autoshrink', true
GO
EXEC SP_DBOPTION 'RSA', 'trunc. log on chkpt.', true
GO
CHECKPOINT
GO
USE MASTER
GO
CREATE LOGIN RSA_DBA WITH PASSWORD = 'VMware1!', DEFAULT_DATABASE = RSA
GO
CREATE LOGIN RSA_USER WITH PASSWORD = 'VMware1!', DEFAULT_DATABASE = RSA
GO
USE RSA
GO
ALTER AUTHORIZATION ON DATABASE::RSA TO [RSA_DBA]
GO
CREATE USER RSA_USER FOR LOGIN [RSA_USER]
GO
CHECKPOINT
GO

View File

@ -0,0 +1,24 @@
@echo off
echo **
echo * Connect to build share
net use B: \\192.168.199.7\Build
type B:\automate\version.txt >> C:\buildlog.txt
echo **
echo * Copy PowerShell files
echo * Copy PowerShell files
copy B:\Automate\validate.ps1 C:\
copy B:\Automate\PSFunctions.ps1 C:\
copy B:\Automate\PXEMenuConfig.ps1 C:\
copy B:\Automate\DC2\Phase2.ps1 C:\
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
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 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

View File

@ -0,0 +1,292 @@
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 Build.ps1"
Read-Host "Press <Enter> to exit"
exit
}
# Start DC configuration process
if (Test-Path B:\Automate\automate.ini) {
$AdminPWD = "VMware1!"
$AdminPWD = ((Select-String -SimpleMatch "Adminpwd=" -Path "B:\Automate\automate.ini").line).substring(9)
B:\automate\_Common\Autologon administrator lab $AdminPWD
}
Write-BuildLog "Correct DNS client settings"
$wmi = Get-WmiObject win32_networkadapterconfiguration -filter "ipenabled = 'true'"
$null = $wmi.SetDNSServerSearchOrder("192.160.201.4")
Write-BuildLog "Installing 7-zip."
try {
msiexec /qb /i B:\Automate\_Common\7z920-x64.msi
Write-BuildLog "Installation of 7-zip completed."
}
catch {
Write-BuildLog "7-zip installation failed."
}
Write-BuildLog ""
Write-BuildLog "Installing TFTP."
Write-BuildLog "Creating C:\TFTP-Root directory."
$null = $null = New-Item -Path C:\TFTP-Root -ItemType Directory -Force -Confirm:$false
Write-BuildLog "Creating C:\Program Files\Tftpd64_SE directory."
$null = $null = New-Item -Path "C:\Program Files\Tftpd64_SE" -ItemType Directory -Force -Confirm:$false
xcopy B:\Automate\DC2\Tftpd64_SE\*.* "C:\Program Files\Tftpd64_SE\" /s /c /y /q
Start-Sleep -Seconds 30
Start-Process "C:\Program Files\Tftpd64_SE\Tftpd64_SVC.exe" -ArgumentList "-install" -Wait
Write-BuildLog "Setting TFTP service startup type and starting it."
$null = Set-Service -Name "Tftpd32_svc" -StartupType "Automatic"
$null = Start-Service -Name "Tftpd32_svc"
Write-BuildLog "Copying B:\Automate\DC2\TFTP-Root\ contents to C:\TFTP-Root."
xcopy B:\Automate\DC2\TFTP-Root\*.* C:\TFTP-Root\ /s /c /y /q
Write-BuildLog "Installation of TFTP completed."
Write-BuildLog ""
Write-BuildLog "Checking for VMware Tools..."
if (Test-Path -Path "B:\VMTools\setup*") {
Write-BuildLog "VMware Tools found."
$vmtools = $true
} else {
if (Test-Path "B:\VMTools\windows.iso") {
Write-BuildLog "Extracting VMware Tools from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\VMtools\ B:\VMTools\windows.iso >> C:\BuildLog.txt
$vmtools = $true
}
Else {Write-BuildLog "VMware Tools not found on Build share."}
Write-BuildLog ""
}
Write-BuildLog "Checking for vSphere files..."
if (Test-Path "B:\ESXi55\*") {
if (Test-Path "B:\ESXi55\*.iso") {
Write-BuildLog "Extracting ESXi 5.5 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESXi55\ B:\ESXi55\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESXi 5.5 found; creating C:\TFTP-Root\ESXi55 and copying ESXi 5.5 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESXi55 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESXi55\*.* C:\TFTP-Root\ESXi55 /s /c /y /q
Get-Content C:\TFTP-Root\ESXi55\BOOT.CFG | %{$_ -replace "/","/ESXi55/"} | Set-Content C:\TFTP-Root\ESXi55\Besx11-55.cfg
Add-Content C:\TFTP-Root\ESXi55\\Besx11-55.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx11-5.cfg"
Get-Content C:\TFTP-Root\ESXi55\BOOT.CFG | %{$_ -replace "/","/ESXi55/"} | Set-Content C:\TFTP-Root\ESXi55\Besx12-55.cfg
Add-Content C:\TFTP-Root\ESXi55\\Besx12-55.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx12-5.cfg"
powershell C:\PXEMenuConfig.ps1 ESXi55
Write-BuildLog "ESXi 5.5 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi55 = $true
} else {
$esxi55 = $false
}
if (Test-Path "B:\ESXi51\*") {
if (Test-Path "B:\ESXi51\*.iso") {
Write-BuildLog "Extracting ESXi 5.1 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESXi51\ B:\ESXi51\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESXi 5.1 found; creating C:\TFTP-Root\ESXi51 and copying ESXi 5.1 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESXi51 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESXi51\*.* C:\TFTP-Root\ESXi51 /s /c /y /q
Get-Content C:\TFTP-Root\ESXi51\BOOT.CFG | %{$_ -replace "/","/ESXi51/"} | Set-Content C:\TFTP-Root\ESXi51\Besx1-5.cfg
Add-Content C:\TFTP-Root\ESXi51\Besx1-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx1-5.cfg"
Get-Content C:\TFTP-Root\ESXi51\BOOT.CFG | %{$_ -replace "/","/ESXi51/"} | Set-Content C:\TFTP-Root\ESXi51\Besx2-5.cfg
Add-Content C:\TFTP-Root\ESXi51\Besx2-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx2-5.cfg"
Get-Content C:\TFTP-Root\ESXi51\BOOT.CFG | %{$_ -replace "/","/ESXi51/"} | Set-Content C:\TFTP-Root\ESXi51\Besx3-5.cfg
Add-Content C:\TFTP-Root\ESXi51\Besx3-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg"
Get-Content C:\TFTP-Root\ESXi51\BOOT.CFG | %{$_ -replace "/","/ESXi51/"} | Set-Content C:\TFTP-Root\ESXi51\Besx4-5.cfg
Add-Content C:\TFTP-Root\ESXi51\Besx4-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg"
powershell C:\PXEMenuConfig.ps1 ESXi51
Write-BuildLog "ESXi 5.1 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi51 = $true
} else {
$esxi51 = $false
}
if (Test-Path "B:\ESXi50\*") {
if (Test-Path "B:\ESXi50\*.iso") {
Write-BuildLog "Extracting ESXi 5.0 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESXi50\ B:\ESXi50\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESXi 5.0 found; creating C:\TFTP-Root\ESXi50 and copying ESXi 5.0 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESXi50 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESXi50\*.* C:\TFTP-Root\ESXi50 /s /c /y /q
Get-Content C:\TFTP-Root\ESXi50\BOOT.CFG | %{$_ -replace "/","/ESXi50/"} | Set-Content C:\TFTP-Root\ESXi50\Besx1-5.cfg
Add-Content C:\TFTP-Root\ESXi50\Besx1-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx1-5.cfg"
Get-Content C:\TFTP-Root\ESXi50\BOOT.CFG | %{$_ -replace "/","/ESXi50/"} | Set-Content C:\TFTP-Root\ESXi50\Besx2-5.cfg
Add-Content C:\TFTP-Root\ESXi50\Besx2-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx2-5.cfg"
Get-Content C:\TFTP-Root\ESXi50\BOOT.CFG | %{$_ -replace "/","/ESXi50/"} | Set-Content C:\TFTP-Root\ESXi50\Besx3-5.cfg
Add-Content C:\TFTP-Root\ESXi50\Besx3-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx3-5.cfg"
Get-Content C:\TFTP-Root\ESXi50\BOOT.CFG | %{$_ -replace "/","/ESXi50/"} | Set-Content C:\TFTP-Root\ESXi50\Besx4-5.cfg
Add-Content C:\TFTP-Root\ESXi50\Besx4-5.cfg "kernelopt=ks=nfs://192.168.199.7/mnt/LABVOL/Build/Automate/Hosts/esx4-5.cfg"
powershell C:\PXEMenuConfig.ps1 ESXi50
Write-BuildLog "ESXi 5.0 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi50 = $true
} else {
$esxi50 = $false
}
if (Test-Path "B:\ESXi41\*") {
if (Test-Path "B:\ESXi41\*.iso") {
Write-BuildLog "Extracting ESXi 4.1 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESXi41\ B:\ESXi41\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESXi 4.1 found; creating C:\TFTP-Root\ESXi41 and copying ESXi 4.1 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESXi41 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESXi41\vmkboot.gz C:\TFTP-Root\ESXi41 /s /c /y /q
xcopy B:\ESXi41\vmkernel.gz C:\TFTP-Root\ESXi41 /s /c /y /q
xcopy B:\ESXi41\sys.vgz C:\TFTP-Root\ESXi41 /s /c /y /q
xcopy B:\ESXi41\cim.vgz C:\TFTP-Root\ESXi41 /s /c /y /q
xcopy B:\ESXi41\ienviron.vgz C:\TFTP-Root\ESXi41 /s /c /y /q
xcopy B:\ESXi41\install.vgz C:\TFTP-Root\ESXi41 /s /c /y /q
xcopy B:\ESXi41\mboot.c32 C:\TFTP-Root\ESXi41 /s /c /y /q
powershell C:\PXEMenuConfig.ps1 ESXi41
Write-BuildLog "ESXi 4.1 added to TFTP and PXE menu."
Write-BuildLog ""
$esxi41 = $true
} else {
$esxi41 = $false
}
if (Test-Path "B:\ESX41\*") {
if (Test-Path "B:\ESX41\*.iso") {
Write-BuildLog "Extracting ESX 4.1 installer from ISO."
. "C:\Program Files\7-Zip\7z.exe" x -r -y -aoa -oB:\ESX41\ B:\ESX41\*.iso >> C:\ExtractLog.txt
}
Write-BuildLog "ESX 4.1 found; creating C:\TFTP-Root\ESX41 and copying ESX 4.1 boot files."
$null = $null = New-Item -Path C:\TFTP-Root\ESX41 -ItemType Directory -Force -Confirm:$false
xcopy B:\ESX41\isolinux\vmlinuz C:\TFTP-Root\ESX41 /s /c /y /q
xcopy B:\ESX41\isolinux\initrd.img C:\TFTP-Root\ESX41 /s /c /y /q
powershell C:\PXEMenuConfig.ps1 ESX41
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)) {
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."
exit
}
Write-BuildLog ""
Write-BuildLog "Authorise and configure DHCP"
netsh dhcp add server dc2.lab.local 192.168.201.4
netsh dhcp server 192.168.201.4 add scope 192.168.201.0 255.255.255.0 "Lab scope" "Scope for lab.local"
netsh dhcp server 192.168.201.4 scope 192.168.201.0 add iprange 192.168.201.100 192.168.201.199
netsh dhcp server 192.168.201.4 scope 192.168.201.0 set optionvalue 003 IPADDRESS 192.168.201.2
netsh dhcp server 192.168.201.4 scope 192.168.201.0 set optionvalue 005 IPADDRESS 192.168.201.4
netsh dhcp server 192.168.201.4 scope 192.168.201.0 set optionvalue 006 IPADDRESS 192.168.201.4
netsh dhcp server 192.168.201.4 scope 192.168.201.0 set optionvalue 015 STRING lab.local
netsh dhcp server 192.168.201.4 scope 192.168.201.0 set optionvalue 066 STRING 192.168.201.4
netsh dhcp server 192.168.201.4 scope 192.168.201.0 set optionvalue 067 STRING pxelinux.0
netsh dhcp server 192.168.201.4 scope 192.168.201.0 set state 1
Write-BuildLog ""
Write-BuildLog "Checking available SQL Express versions."
$null = $null = New-Item -Path C:\temp -ItemType Directory -Force -Confirm:$false
Write-BuildLog ""
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_55\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") {
$vc5SQL = $true
Write-BuildLog "SQL Server 2008 R2 Express SP1 for vCenter 5.5 found; installing."
copy B:\VIM_55\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\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc2\SQLEXPRESS -i B:\Automate\DC2\MakeDB.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc2\SQLEXPRESS -i B:\Automate\DC2\MakeDBvCD51.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc2\SQLEXPRESS -i B:\Automate\DC2\MakeDBvCD15.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
regedit -s B:\Automate\DC2\SQLTCP.reg
} elseif (Test-Path "B:\VIM_51\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") {
$vc5SQL = $true
Write-BuildLog "SQL Server 2008 R2 Express SP1 for vCenter 5.1 found; installing."
copy B:\VIM_51\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
Write-BuildLog "Creating Databases."
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc2\SQLEXPRESS -i B:\Automate\DC2\MakeDB.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc2\SQLEXPRESS -i B:\Automate\DC2\MakeDBvCD51.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc2\SQLEXPRESS -i B:\Automate\DC2\MakeDBvCD15.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
regedit -s B:\Automate\DC2\SQLTCP.reg
} elseif (Test-Path "B:\VIM_50\redist\SQLEXPR\SQLEXPR_x64_ENU.exe") {
$vc5SQL = $true
Write-BuildLog "SQL Server 2008 R2 Express SP1 for vCenter 5.0 found; installing."
copy B:\VIM_50\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
Write-BuildLog "Creating Databases."
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc2\SQLEXPRESS -i B:\Automate\DC2\MakeDB.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
Start-Process "C:\Program Files\Microsoft SQL Server\100\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc2\SQLEXPRESS -i B:\Automate\DC2\MakeDBvCD15.txt" -RedirectStandardOutput c:\sqllog.txt -Wait
regedit -s B:\Automate\DC2\SQLTCP.reg
} elseif (Test-Path "B:\VIM_41\redist\SQLEXPR\x64\SQLEXPR.EXE") {
copy B:\VIM_41\redist\SQLEXPR\x64\SQLEXPR.EXE C:\temp
Write-BuildLog "SQL Server 2005 Express for vCenter 4.1 found; installing."
$Arguments = '/qb INSTANCENAME=SQLExpress ADDLOCAL=ALL SAPWD="VMware1!" SQLACCOUNT="Lab\vi-admin" SQLPASSWORD="' + $AdminPWD + '" AGTACCOUNT="Lab\vi-admin" AGTPASSWORD="' + $AdminPWD + '" SQLBROWSERACCOUNT="Lab\vi-admin" SQLBROWSERPASSWORD="' + $AdminPWD + '" DISABLENETWORKPROTOCOLS=0'
Start-Process C:\temp\SQLEXPR_x64_ENU.exe -ArgumentList $Arguments -Wait
Write-BuildLog "Creating Databases."
Start-Process "C:\Program Files (x86)\Microsoft SQL Server\90\Tools\Binn\sqlcmd.exe" -ArgumentList "-S dc2\SQLEXPRESS -i B:\Automate\DC2\MakeDB41.txt" -RedirectStandardOutput c:\sqllog.txt -Wait; type C:\sqllog.txt | add-content C:\buildlog.txt
regedit -s B:\Automate\DC2\SQLTCP.reg
} else {
$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."
Read-Host "Press <ENTER> to exit"
exit
}
}
If (([System.Environment]::OSVersion.Version.Major -eq 6) -and ([System.Environment]::OSVersion.Version.Minor -lt 2)) {
Write-BuildLog "Setup IIS on Windows 2008"
Start-Process pkgmgr -ArgumentList '/quiet /l:C:\IIS_Install_Log.txt /iu:IIS-WebServerRole;IIS-WebServer;IIS-CommonHttpFeatures;IIS-StaticContent;IIS-DefaultDocument;IIS-DirectoryBrowsing;IIS-HttpErrors;IIS-HttpRedirect;IIS-ApplicationDevelopment;IIS-ASPNET;IIS-NetFxExtensibility;IIS-ASP;IIS-CGI;IIS-ISAPIExtensions;IIS-ISAPIFilter;IIS-ServerSideIncludes;IIS-HealthAndDiagnostics;IIS-HttpLogging;IIS-LoggingLibraries;IIS-RequestMonitor;IIS-HttpTracing;IIS-CustomLogging;IIS-ODBCLogging;IIS-Security;IIS-BasicAuthentication;IIS-WindowsAuthentication;IIS-DigestAuthentication;IIS-ClientCertificateMappingAuthentication;IIS-IISCertificateMappingAuthentication;IIS-URLAuthorization;IIS-RequestFiltering;IIS-IPSecurity;IIS-Performance;IIS-HttpCompressionStatic;IIS-HttpCompressionDynamic;IIS-WebServerManagementTools;IIS-ManagementConsole;IIS-ManagementScriptingTools;IIS-ManagementService;IIS-IIS6ManagementCompatibility;IIS-Metabase;IIS-WMICompatibility;IIS-LegacyScripts;IIS-LegacySnapIn;IIS-FTPPublishingService;IIS-FTPServer;IIS-FTPManagement;WAS-WindowsActivationService;WAS-ProcessModel;WAS-NetFxEnvironment;WAS-ConfigurationAPI' -Wait
}
If (([System.Environment]::OSVersion.Version.Major -eq 6) -and ([System.Environment]::OSVersion.Version.Minor -ge 2)) {
Write-BuildLog "Setup IIS on Windows 2012"
import-module servermanager
$null = add-windowsfeature web-server -includeallsubfeature -source D:\Sources\sxs
Import-Module WebAdministration
New-WebBinding -Name "Default Web Site" -IP "*" -Port 443 -Protocol https
}
if (Test-Path B:\sqlmsssetup.exe) {
Rename-Item B:\sqlmsssetup.exe SQLManagementStudio_x64_ENU.exe
}
if (Test-Path B:\SQLManagementStudio_x64_ENU.exe) {
if ( (!(Get-ChildItem B:\SQLManagementStudio_x64_ENU.exe).VersionInfo.ProductVersion -like "10.50.2500*") -and ($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."
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 "Make Win32Time authoritative for NTP time."
reg add HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\Config /v AnnounceFlags /t REG_DWORD /d 0x05 /f
Write-BuildLog "Cleanup and creating Desktop shortcuts."
reg delete HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run /v Build /f
wscript B:\Automate\DC2\Shortcuts.vbs
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."
tzutil /s "$timezone"
}
Write-BuildLog "Installing VMware tools, build complete after reboot."
Write-BuildLog "(Re)build vCenter next."
if ($vmtools) {
Start-Process B:\VMTools\setup64.exe -ArgumentList '/s /v "/qn"' -Verb RunAs -Wait
Start-Sleep -Seconds 30
}
Read-Host "Press <ENTER> to exit"

Binary file not shown.

View File

@ -0,0 +1,14 @@
set WshShell = WScript.CreateObject("WScript.Shell")
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\BuildLog.lnk")
oShortCutLink.TargetPath = "c:\BuildLog.txt"
oShortCutLink.Save
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\Validate.lnk")
oShortCutLink.TargetPath = "%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe"
oShortCutLink.Arguments = " c:\validate.ps1"
oShortCutLink.Save
set oShortCutLink = WshShell.CreateShortcut("C:\Users\Public\Desktop\Upgrade.lnk")
oShortCutLink.TargetPath = "\\nas\Build\Automate\DC2\Upgrade.cmd"
oShortCutLink.Save

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,23 @@
MENU TITLE ESXi 5.0 installs
LABEL Main Menu
MENU LABEL ^Return to Main Menu
KERNEL pxelinux.cfg/vesamenu.c32
APPEND pxelinux.cfg/default
label esx50
KERNEL /esxi50/mboot.c32
APPEND -c /esxi50/boot.cfg
MENU LABEL ESXi 5.0 Manual Install
label esx1-5
KERNEL /esxi50/mboot.c32
APPEND -c /esxi50/Besx11-5.cfg
MENU LABEL Host11 Automated Install
Label ESX2-5
KERNEL /esxi50/mboot.c32
APPEND -c /esxi50/Besx12-5.cfg
MENU LABEL Host12 Automated Install

View File

@ -0,0 +1,22 @@
MENU TITLE ESXi 5.1 installs
LABEL Main Menu
MENU LABEL ^Return to Main Menu
KERNEL pxelinux.cfg/vesamenu.c32
APPEND pxelinux.cfg/default
label esx51
KERNEL /esxi51/mboot.c32
APPEND -c /esxi51/boot.cfg
MENU LABEL ESXi 5.1 Manual Install
label ESX1-5
KERNEL /esxi51/mboot.c32
APPEND -c /esxi51/Besx11-5.cfg
MENU LABEL Host11 Automated Install
Label ESX2-5
KERNEL /esxi51/mboot.c32
APPEND -c /esxi51/Besx12-5.cfg
MENU LABEL Host12 Automated Install

View File

@ -0,0 +1,22 @@
MENU TITLE ESXi 5.5 installs
LABEL Main Menu
MENU LABEL ^Return to Main Menu
KERNEL pxelinux.cfg/vesamenu.c32
APPEND pxelinux.cfg/default
label esx55
KERNEL /esxi55/mboot.c32
APPEND -c /esxi55/boot.cfg
MENU LABEL ESXi 5.5 Manual Install
label ESX1-5
KERNEL /esxi55/mboot.c32
APPEND -c /esxi55/Besx11-55.cfg
MENU LABEL Host11 Automated Install
Label ESX2-5
KERNEL /esxi55/mboot.c32
APPEND -c /esxi55/Besx12-55.cfg
MENU LABEL Host12 Automated Install

Binary file not shown.

View File

@ -0,0 +1,23 @@
menu title AutoLab PXE Menu
menu tabmsgrow 22
menu cmdlinerow 22
menu endrow 24
menu color title 1;34;49 #eea0a0ff #cc333355 std
menu color sel 7;37;40 #ff000000 #bb9999aa all
menu color border 30;44 #ffffffff #00000000 std
menu color pwdheader 31;47 #eeff1010 #20ffffff std
menu color hotkey 35;40 #90ffff00 #00000000 std
menu color hotsel 35;40 #90000000 #bb9999aa all
menu color timeout_msg 35;40 #90ffffff #00000000 none
menu color timeout 31;47 #eeff1010 #00000000 none
prompt 0
noescape 1
timeout 300
default pxelinux.cfg/vesamenu.c32
label localboot
menu label Boot local hard disk
kernel pxelinux.cfg/chain.c32
append hd0 0

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1 @@
TFTPD32 is copyrighted 1998-2011 by Philippe Jounin (philippe@jounin.net) and released under the European Union Public License (see file EUPL-EN.pdf).

Binary file not shown.

View File

@ -0,0 +1,37 @@
[DHCP]
Lease_NumLeases=0
[TFTPD32]
BaseDirectory=C:\TFTP-Root
TftpPort=69
Hide=0
WinSize=0
Negociate=1
PXECompatibility=0
DirText=0
ShowProgressBar=1
Timeout=3
MaxRetransmit=6
SecurityLevel=1
UnixStrings=1
Beep=0
VirtualRoot=0
MD5=0
LocalIP=
Services=1
TftpLogFile=
SaveSyslogFile=
PipeSyslogMsg=0
LowestUDPPort=0
HighestUDPPort=0
MulticastPort=0
MulticastAddress=
PersistantLeases=1
DHCP Ping=1
DHCP LocalIP=
Max Simultaneous Transfers=100
UseEventLog=0
Console Password=tftpd32
Support for port Option=0
Keep transfer Gui=5
Ignore ack for last TFTP packet=0
Enable IPv6=0

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,6 @@
$NICs = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled=TRUE"
$Null = $NICs.SetGateways("192.168.199.2")
$NICs = Get-WmiObject -Class Win32_NetworkAdapterConfiguration -Filter "IPEnabled=TRUE"
Write-Host "Added gateway. "
Write-Host "Make sure the lab Router VM is running. "
Read-Host "Press <Enter> to exit"

View File

@ -0,0 +1,6 @@
vmaccepteula
rootpw VMware1!
autopart --firstdisk --overwritevmfs
install nfs --server=192.168.199.7 --dir=/mnt/LABVOL/Build/ESXi41
network --device=vmnic0 --bootproto=static --ip=192.168.199.11 --gateway=192.168.199.2 --nameserver=192.168.199.4 --netmask=255.255.255.0 --hostname=host1.lab.local --addvmportgroup=1
reboot

View File

@ -0,0 +1,11 @@
vmaccepteula
rootpw VMware1!
install --firstdisk --overwritevmfs
network --bootproto=static --ip=192.168.199.11 --gateway=192.168.199.2 --nameserver=192.168.199.4 --netmask=255.255.255.0 --hostname=host1.lab.local --device=vmnic0 --addvmportgroup=1
reboot
%firstboot --interpreter=busybox
esxcli storage nmp satp rule add --satp VMW_SATP_LOCAL --device mpx.vmhba1:C0:T1:L0 --option "enable_ssd"
esxcfg-nas -a -o 192.168.199.7 -s /mnt/LABVOL/Build Build
esxcli software vib install -v /vmfs/volumes/Build/Automate/Hosts/esx-tools-for-esxi-9.7.1-0.0.00000.i386.vib -f
echo 'vmx.allowNested = "TRUE"' >> /etc/vmware/config

View File

@ -0,0 +1,10 @@
vmaccepteula
rootpw VMware1!
install --firstdisk --overwritevmfs
network --bootproto=static --ip=192.168.201.11 --gateway=192.168.201.2 --nameserver=192.168.201.4 --netmask=255.255.255.0 --hostname=host11.lab.local --device=vmnic0 --addvmportgroup=1
reboot
%firstboot --interpreter=busybox
esxcfg-nas -a -o 192.168.199.7 -s /mnt/LABVOL/Build Build
esxcli software vib install -v /vmfs/volumes/Build/Automate/Hosts/esx-tools-for-esxi-9.7.1-0.0.00000.i386.vib -f
echo 'vmx.allowNested = "TRUE"' >> /etc/vmware/config

View File

@ -0,0 +1,10 @@
vmaccepteula
rootpw VMware1!
install --firstdisk --overwritevmfs
network --bootproto=static --ip=192.168.201.12 --gateway=192.168.201.2 --nameserver=192.168.201.4 --netmask=255.255.255.0 --hostname=host12.lab.local --device=vmnic0 --addvmportgroup=1
reboot
%firstboot --interpreter=busybox
esxcfg-nas -a -o 192.168.199.7 -s /mnt/LABVOL/Build Build
esxcli software vib install -v /vmfs/volumes/Build/Automate/Hosts/esx-tools-for-esxi-9.7.1-0.0.00000.i386.vib -f
echo 'vmx.allowNested = "TRUE"' >> /etc/vmware/config

View File

@ -0,0 +1,6 @@
vmaccepteula
rootpw VMware1!
autopart --firstdisk --overwritevmfs
install nfs --server=192.168.199.7 --dir=/mnt/LABVOL/Build/ESXi41
network --device=vmnic0 --bootproto=static --ip=192.168.199.12 --gateway=192.168.199.2 --nameserver=192.168.199.4 --netmask=255.255.255.0 --hostname=host2.lab.local --addvmportgroup=1
reboot

View File

@ -0,0 +1,29 @@
#root Password
rootpw VMware1!
# Authconfig
# authconfig --enableshadow --enablemd5
# BootLoader (Use grub by default.)
bootloader --location=mbr
# Timezone
timezone America/Los_Angeles
#Install
install nfs --server=192.168.199.7 --dir=/mnt/LABVOL/Build/ESX41
#Network install type
network --bootproto=static --ip=192.168.199.12 --gateway=192.168.199.2 --nameserver=192.168.199.4 --netmask=255.255.255.0 --hostname=host2.lab.local --device=vmnic0 --addvmportgroup=1
#Keyboard
keyboard us
#Reboot after install?
reboot
# Clear partitions
clearpart --firstdisk --overwritevmfs
# Partitioning
part /boot --fstype=ext3 --size=1200 --onfirstdisk
part storage1 --fstype=vmfs3 --size=10000 --grow --onfirstdisk
part None --fstype=vmkcore --size=100 --onfirstdisk
# Create the vmdk on the cos vmfs partition.
virtualdisk cos --size=5000 --onvmfs=storage1
# Partition the virtual disk.
part / --fstype=ext3 --size=3600 --grow --onvirtualdisk=cos
part swap --fstype=swap --size=256 --onvirtualdisk=cos
#VMware Specific Commands
accepteula

View File

@ -0,0 +1,11 @@
vmaccepteula
rootpw VMware1!
install --firstdisk --overwritevmfs
network --bootproto=static --ip=192.168.199.12 --gateway=192.168.199.2 --nameserver=192.168.199.4 --netmask=255.255.255.0 --hostname=host2.lab.local --device=vmnic0 --addvmportgroup=1
reboot
%firstboot --interpreter=busybox
esxcli storage nmp satp rule add --satp VMW_SATP_LOCAL --device mpx.vmhba1:C0:T1:L0 --option "enable_ssd"
esxcfg-nas -a -o 192.168.199.7 -s /mnt/LABVOL/Build Build
esxcli software vib install -v /vmfs/volumes/Build/Automate/Hosts/esx-tools-for-esxi-9.7.1-0.0.00000.i386.vib -f
echo 'vmx.allowNested = "TRUE"' >> /etc/vmware/config

View File

@ -0,0 +1,11 @@
vmaccepteula
rootpw VMware1!
install --firstdisk --overwritevmfs
network --bootproto=static --ip=192.168.199.13 --gateway=192.168.199.2 --nameserver=192.168.199.4 --netmask=255.255.255.0 --hostname=host3.lab.local --device=vmnic0 --addvmportgroup=1
reboot
%firstboot --interpreter=busybox
esxcli storage nmp satp rule add --satp VMW_SATP_LOCAL --device mpx.vmhba1:C0:T1:L0 --option "enable_ssd"
esxcfg-nas -a -o 192.168.199.7 -s /mnt/LABVOL/Build Build
esxcli software vib install -v /vmfs/volumes/Build/Automate/Hosts/esx-tools-for-esxi-9.7.1-0.0.00000.i386.vib -f
echo 'vmx.allowNested = "TRUE"' >> /etc/vmware/config

Some files were not shown because too many files have changed in this diff Show More