How to retrieve Avamar Serial Numbers via SSH
mapall --noerror --user=root --nodes=all+ --quiet 'echo `hostname -i`": "`/usr/bin/ipmitool fru print 0 | grep "Product Asset Tag" | sed "s/^.*:\s\(.*$\)/\1/"`'
$Datacentre = Get-Datacenter -Name Datacentre_01 New-VDSwitch -Name vdSwitch_iSCSI -Location $Datacentre -NumUplinkPorts 2 -MaxPorts 256 -Version "6.0.0" -Mtu 9000 | Out-Null
Get-VDSwitch -Name vdSwitch_iSCSI | Get-VDPortgroup | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort dvUplink1 -UnusedUplinkPort dvUplink2 Get-VDSwitch -Name vdSwitch_iSCSI | New-VDPortgroup -Name vdPG_iSCSI1 -NumPorts 120 -VLanId 230 -PortBinding Ephemeral Get-VDSwitch -Name vdSwitch_iSCSI | New-VDPortgroup -Name vdPG_iSCSI2 -NumPorts 120 -VLanId 230 -PortBinding Ephemeral Get-VDSwitch -Name vdSwitch_iSCSI | Get-VDPortgroup -Name vdPG_iSCSI2 | Get-VDPortgroupOverridePolicy | Set-VDPortgroupOverridePolicy -UplinkTeamingOverrideAllowed $true Get-VDSwitch -Name vdSwitch_iSCSI | Get-VDPortgroup -Name vdPG_iSCSI2 | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort dvUplink2 -UnusedUplinkPort dvUplink1
Get-VDSwitch -Name vdSwitch_iSCSI | Add-VDSwitchVMHost -VMHost esx-01.localdomain.local $nic2 = Get-VMHost -Name esx-01.localdomain.local | Get-VMHostNetworkAdapter -Physical -Name vmnic2 $nic3 = Get-VMHost -Name esx-01.localdomain.local | Get-VMHostNetworkAdapter -Physical -Name vmnic3 Get-VDSwitch -Name $vdSwitch_iSCSI_Name | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $nic2 -Confirm:$false Get-VDSwitch -Name $vdSwitch_iSCSI_Name | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $nic3 -Confirm:$false
New-VMHostNetworkAdapter -VMHost esx-01.localdomain.local -VirtualSwitch vdSwitch_iSCSI -PortGroup vdPG_iSCSI1 -IP 192.168.101.1 -SubnetMask 255.255.255.0 -Mtu 9000 New-VMHostNetworkAdapter -VMHost esx-01.localdomain.local -VirtualSwitch vdSwitch_iSCSI -PortGroup vdPG_iSCSI2 -IP 192.168.101.101 -SubnetMask 255.255.255.0 -Mtu 9000
Get-VMHostStorage -VMHost $HostName | Set-VMHostStorage -SoftwareIScsiEnabled $true
$iSCSI1_nic = Get-VMHostNetworkAdapter -VMHost esx-01.localdomain.local | where {$_.IP -like "192.168.101.1"} | select Name $iSCSI2_nic = Get-VMHostNetworkAdapter -VMHost esx-01.localdomain.local | where {$_.IP -like "192.168.101.101"} | select Name $HBANumber = Get-VMHostHba -VMHost esx-01.localdomain.local -Type iSCSI | %{$_.Device} $esxcli = Get-EsxCli -VMHost esx-01.localdomain.local $esxcli.iscsi.networkportal.add($HBANumber,$true,$iSCSI1_nic.Name) $esxcli.iscsi.networkportal.add($HBANumber,$true,$iSCSI2_nic.Name)
$HBANumber = Get-VMHostHba -VMHost esx-01.localdomain.local -Type iSCSI | %{$_.Device} New-IScsiHbaTarget -IScsiHba $HBANumber -Address "192.168.101.201" Get-VMHostStorage -VMHost esx-01.localdomain.local -RescanAllHba Get-VMHostStorage -VMHost esx-01.localdomain.local -RescanVmfs
$HostView = Get-VMHost esx-01.localdomain.local | Get-View $HostStorageSystemID = $HostView.configmanager.StorageSystem $HBANumber = ($HostView.config.storagedevice.HostBusAdapter | where {$_.Model -match "iSCSI Software"}).device $options = New-Object VMWare.Vim.HostInternetScsiHbaParamValue[] (2) $options[0] = New-Object VMware.Vim.HostInternetScsiHbaParamValue $options[0].key = "DelayedAck" $options[0].value = $false $options[1] = New-Object VMware.Vim.HostInternetScsiHbaParamValue $options[1].key = "LoginTimeout" $options[1].value = 60 $HostStorageSystem = Get-View -ID $HostStorageSystemID $HostStorageSystem.UpdateInternetScsiAdvancedOptions($HBANumber , $null, $options)
$VIUser="administrator" $VIPassword="password" $DatacentreName="Datacentre_01" $vdSwitch_iSCSI_Name="vdSwitch_iSCSI" $vdPG_iSCSI1="vdPG_iSCSI_1" $vdPG_iSCSI2="vdPG_iSCSI_2" $iSCSI1_Net="192.168.101." $iSCSI1_StartIP=1 $iSCSI1_NetMask="255.255.255.0" $iSCSI2_Net="192.168.101." $iSCSI2_StartIP=101 $iSCSI2_NetMask="255.255.255.0" $iSCSI_Targets=@("192.168.101.201","192.168.101.202") $HostNames=@("esx-01.localdomain.local","esx-02.localdomain.local") Connect-VIServer vcentre.localdomain.local -User $VIUser -Password $VIPassword | Out-Null $Datacentre = Get-Datacenter -Name $DatacentreName New-VDSwitch -Name $vdSwitch_iSCSI_Name -Location $Datacentre -NumUplinkPorts 2 -MaxPorts 256 -Version "6.0.0" -Mtu 9000 | Out-Null Get-VDSwitch -Name $vdSwitch_iSCSI_Name | Get-VDPortgroup | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort dvUplink1 -UnusedUplinkPort dvUplink2 Get-VDSwitch -Name $vdSwitch_iSCSI_Name | New-VDPortgroup -Name $vdPG_iSCSI1 -NumPorts 120 -VLanId 230 -PortBinding Ephemeral Get-VDSwitch -Name $vdSwitch_iSCSI_Name | New-VDPortgroup -Name $vdPG_iSCSI2 -NumPorts 120 -VLanId 230 -PortBinding Ephemeral Get-VDSwitch -Name $vdSwitch_iSCSI_Name | Get-VDPortgroup -Name $vdPG_iSCSI2 | Get-VDPortgroupOverridePolicy | Set-VDPortgroupOverridePolicy -UplinkTeamingOverrideAllowed $true Get-VDSwitch -Name $vdSwitch_iSCSI_Name | Get-VDPortgroup -Name $vdPG_iSCSI2 | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort dvUplink2 -UnusedUplinkPort dvUplink1 $options = New-Object VMWare.Vim.HostInternetScsiHbaParamValue[] (2) $options[0] = New-Object VMware.Vim.HostInternetScsiHbaParamValue $options[0].key = "DelayedAck" $options[0].value = $false $options[1] = New-Object VMware.Vim.HostInternetScsiHbaParamValue $options[1].key = "LoginTimeout" $options[1].value = 60 foreach ($HostName in $HostNames){ $iSCSI1_IP=$iSCSI1_Net+$iSCSI1_StartIP $iSCSI2_IP=$iSCSI2_Net+$iSCSI2_StartIP Get-VDSwitch -Name $vdSwitch_iSCSI_Name | Add-VDSwitchVMHost -VMHost $HostName $nic2 = Get-VMHost -Name $HostName | Get-VMHostNetworkAdapter -Physical -Name vmnic2 $nic3 = Get-VMHost -Name $HostName | Get-VMHostNetworkAdapter -Physical -Name vmnic3 Get-VDSwitch -Name $vdSwitch_iSCSI_Name | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $nic2 -Confirm:$false Get-VDSwitch -Name $vdSwitch_iSCSI_Name | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $nic3 -Confirm:$false New-VMHostNetworkAdapter -VMHost $HostName -VirtualSwitch $vdSwitch_iSCSI_Name -PortGroup $vdPG_iSCSI1 -IP $iSCSI1_IP -SubnetMask $iSCSI1_NetMask -Mtu 9000 | Out-Null $iSCSI1_nic = Get-VMHostNetworkAdapter -VMHost $HostName | where {$_.IP -like $iSCSI1_IP} | select Name New-VMHostNetworkAdapter -VMHost $HostName -VirtualSwitch $vdSwitch_iSCSI_Name -PortGroup $vdPG_iSCSI2 -IP $iSCSI2_IP -SubnetMask $iSCSI2_NetMask -Mtu 9000 | Out-Null $iSCSI2_nic = Get-VMHostNetworkAdapter -VMHost $HostName | where {$_.IP -like $iSCSI2_IP} | select Name Get-VMHostStorage -VMHost $HostName | Set-VMHostStorage -SoftwareIScsiEnabled $true | Out-Null $HBANumber = Get-VMHostHba -VMHost $HostName -Type iSCSI | %{$_.Device} $esxcli = Get-EsxCli -VMHost $HostName $esxcli.iscsi.networkportal.add($HBANumber,$true,$iSCSI1_nic.Name) $esxcli.iscsi.networkportal.add($HBANumber,$true,$iSCSI2_nic.Name) $HostView = Get-VMHost $HostName | Get-View $HostStorageSystemID = $HostView.configmanager.StorageSystem $HostStorageSystem = Get-View -ID $HostStorageSystemID $HostStorageSystem.UpdateInternetScsiAdvancedOptions($HBANumber , $null, $options) foreach ($iSCSI_Target in $iSCSI_Targets){ New-IScsiHbaTarget -IScsiHba $HBANumber -Address $iSCSI_Target } Get-VMHostStorage -VMHost $HostName -RescanAllHba Get-VMHostStorage -VMHost $HostName -RescanVmfs } Disconnect-VIServer -Confirm:$false
Connect-VIServer vcentre.localdomain.local
Get-Folder
PowerCLI C:\> Get-Folder Name Type ---- ---- Datacenters Datacenter vm VM network Network host HostAndCluster datastore Datastore Discovered virtual machine VM
New-Datacenter -Location Datacenters -Name Datacentre_01
New-Cluster -Name Cluster_01 -Location "Datacentre_01"
Get-Cluster -Name Cluster_01 | Set-Cluster -Name Cluster_01 -HAEnabled:$true -HAAdmissionControlEnabled:$true -HAFailover 1 -VMSwapfilePolicy "WithVM" -HARestartPriority "Low" -HAIsolationResponse "DoNothing" -Confirm:$false
Set-Cluster -Cluster Cluster_01 -DRSEnabled:$true -DRSAutomationLevel "FullyAutomated" -Confirm:$false
Set-Cluster -Cluster Cluster_01 -EVCMode "intel-nehalem" -Confirm:$false
Set-Cluster -Cluster Cluster_01 -EVCMode $null -Confirm:$false
Add-VMHost -Name esx-01.localdomain.local -Location Cluster_01 -User root -Password password
Set-VMHost -VMHost esx-01.localdomain.local -State Disconnected Remove-VMHost esx-01.localdomain.local -Confirm:$false
Set-VMHost -VMHost esx-01.localdomain.local -State Maintenance
Get-VMHost -Name esx-01.localdomain.local | Get-VMHostNetworkAdapter | where {$_.DeviceName -like "*nic*"} | select Name
PowerCLI C:\>Get-VMHost -Name esx-01.localdomain.local | Get-VMHostNetworkAdapter | where {$_.DeviceName -like "*nic*"} | select Name Name ---- vmnic0 vmnic1 vmnic2 vmnic3
Get-VMHost -Name esx-01.localdomain.local | Get-VirtualSwitch -Name vSwitch0 | select Nic
PowerCLI C:\>Get-VMHost -Name esx-01.localdomain.local | Get-VirtualSwitch -Name vSwitch0 | select Nic Nic --- {vmnic0}
$nic = Get-VMHost -Name esx-01.localdomain.local | Get-VMHostNetworkAdapter -Physical -Name vmnic1 Get-VMHost -Name esx-01.localdomain.local | Get-VirtualSwitch -Name vSwitch0 | Add-VirtualSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $nic -Confirm:$false
Get-VMHost -Name esx-01.localdomain.local | Get-VirtualSwitch -Name vSwitch0 | New-VirtualPortGroup -Name vPortgroup
Get-VMHost -Name esx-01.localdomain.local | Get-VirtualSwitch -Name vSwitch0 | Get-VirtualPortGroup -Name vPortgroup | Set-VirtualPortGroup -name test -VLanId 120
Get-VMHost -Name esx-01.localdomain.local | Get-VirtualSwitch -Name vSwitch0 | New-VirtualPortGroup -Name vPortgroup -VLanId 120
$Datacentre = Get-Datacenter -Name Datacentre_01 New-VDSwitch -Name vdSwitch0 -Location $Datacentre -NumUplinkPorts 2 -LinkDiscoveryProtocol "LLDP" -LinkDiscoveryProtocolOperation "Listen" -MaxPorts 256 -Version "6.0.0"
Get-VDSwitch -Name vdSwitch0 | Get-VDPortgroup | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort dvUplink1 -StandbyUplinkPort dvUplink2
Get-VDSwitch -Name vdSwitch0 | New-VDPortgroup -Name Production -NumPorts 16 -VLanId 200 -PortBinding Ephemeral
Get-VDSwitch -Name vdSwitch0 | New-VDPortgroup -Name vMotion -NumPorts 16 -VLanId 110 -PortBinding Ephemeral
Get-VDSwitch -Name vdSwitch0 | Get-VDPortgroup -Name vMotion | Get-VDPortgroupOverridePolicy | Set-VDPortgroupOverridePolicy -UplinkTeamingOverrideAllowed $true Get-VDSwitch -Name vdSwitch0 | Get-VDPortgroup -Name vMotion | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort dvUplink2 -StandbyUplinkPort dvUplink1
Get-VDSwitch -Name vdSwitch0 | Add-VDSwitchVMHost -VMHost esx-01.localdomain.local
$nic2 = Get-VMHost -Name esx-01.localdomain.local | Get-VMHostNetworkAdapter -Physical -Name vmnic2 $nic3 = Get-VMHost -Name esx-01.localdomain.local | Get-VMHostNetworkAdapter -Physical -Name vmnic3 Get-VDSwitch -Name vdSwitch0 | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $nic2 -Confirm:$false Get-VDSwitch -Name vdSwitch0 | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $nic3 -Confirm:$false
New-VMHostNetworkAdapter -VMHost esx-01.localdomain.local -VirtualSwitch vdSwitch0 -PortGroup vMotion -IP 192.168.0.1 -SubnetMask 255.255.255.0 -VMotionEnabled:$true
Set-VMHost -VMHost esx-01.localdomain.local -State Connected
$VIUser="administrator" $VIPassword="password" $HostUser="root" $HostPassword="hostpassword" $DatacentreName="Datacentre_01" $ClusterName="Cluster_01" $vSwitchName="vSwitch0" $vdSwitchName="vdSwitch0" $vMotionNet="192.168.0." $VMotionStartIP=1 $VMotionNetMask="255.255.255.0"$HostNames=@("esx-01.localdomain.local","esx-02.localdomain.local") Connect-VIServer vcentre.appv4u.com -User $VIUser -Password $VIPassword New-Datacenter -Location Datacenters -Name $DatacentreName New-Cluster -Name $ClusterName -Location $DatacentreName Get-Cluster -Name $ClusterName | Set-Cluster -Name $ClusterName -HAEnabled:$true -HAAdmissionControlEnabled:$true -HAFailover 1 -VMSwapfilePolicy "WithVM" -HARestartPriority "Low" -HAIsolationResponse "DoNothing" -Confirm:$false Set-Cluster -Cluster $ClusterName -DRSEnabled:$true -DRSAutomationLevel "FullyAutomated" -Confirm:$false Set-Cluster -Cluster $ClusterName -EVCMode "intel-nehalem" -Confirm:$false $Datacentre = Get-Datacenter -Name $DatacentreName New-VDSwitch -Name $vdSwitchName -Location $Datacentre -NumUplinkPorts 2 -LinkDiscoveryProtocol "LLDP" -LinkDiscoveryProtocolOperation "Listen" -MaxPorts 256 -Version "6.0.0" Get-VDSwitch -Name $vdSwitchName | Get-VDPortgroup | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort dvUplink1 -StandbyUplinkPort dvUplink2 Get-VDSwitch -Name $vdSwitchName | New-VDPortgroup -Name Production -NumPorts 16 -VLanId 200 -PortBinding Ephemeral Get-VDSwitch -Name $vdSwitchName | New-VDPortgroup -Name vMotion -NumPorts 16 -VLanId 110 -PortBinding Ephemeral Get-VDSwitch -Name $vdSwitchName | Get-VDPortgroup -Name vMotion | Get-VDPortgroupOverridePolicy | Set-VDPortgroupOverridePolicy -UplinkTeamingOverrideAllowed $true Get-VDSwitch -Name $vdSwitchName | Get-VDPortgroup -Name vMotion | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort dvUplink2 -StandbyUplinkPort dvUplink1 foreach ($HostName in $HostNames){ $VMotionIP=$vMotionNet+$VMotionStartIP Add-VMHost -Name $HostName -Location $ClusterName -User $HostUser -Password $HostPassword | Out-Null Set-VMHost -VMHost $HostName -State Maintenance | Out-Null $nic1 = Get-VMHost -Name $HostName | Get-VMHostNetworkAdapter -Physical -Name vmnic1 Get-VMHost -Name $HostName | Get-VirtualSwitch -Name vSwitch0 | Add-VirtualSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $nic1 -Confirm:$false Get-VDSwitch -Name $vdSwitchName | Add-VDSwitchVMHost -VMHost $HostName $nic2 = Get-VMHost -Name $HostName | Get-VMHostNetworkAdapter -Physical -Name vmnic2 $nic3 = Get-VMHost -Name $HostName | Get-VMHostNetworkAdapter -Physical -Name vmnic3 Get-VDSwitch -Name $vdSwitchName | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $nic2 -Confirm:$false Get-VDSwitch -Name $vdSwitchName | Add-VDSwitchPhysicalNetworkAdapter -VMHostPhysicalNic $nic3 -Confirm:$false New-VMHostNetworkAdapter -VMHost $HostName -VirtualSwitch $vdSwitchName -PortGroup vMotion -IP $VMotionIP -SubnetMask $VMotionNetMask -VMotionEnabled:$true Set-VMHost -VMHost $HostName -State Connected $VMotionStartIP++ $VMotionIP="" } Disconnect-VIServer -Confirm:$false