Welcome to my VMWare resource pool!
"One small step for man, One giant leap for virtualization!
Thursday, May 26, 2016
Tuesday, May 10, 2016
Changing ESXi root passwords the smart way (via PowerCLI)
Changing ESXi passwords the manual way
Steps taken from VM KB 1004659
- Log on to SSH as root, or log on and use “su –“ to get root level access
- Use “passwd root” to change the root password
- Log off and log back on using the new password to test access
Rinse and repeat
Changing ESXi root passwords the smart way (via PowerCLI)
The script is fairly heavily commented, usage is as follows:
.\Change-HostPasswords.ps1 -vCenter VC-01.definit.local -Location “DefinIT Lab”
Source code for this has moved to GitHub to allow a bit more structured collaboration:
PowerCLI Collection – Adding SNMP settings to ESXi hosts Single or vCenter
LINK
The cluster script with a host loop:
#Settings
$vCenterFQDN = Read-Host “Enter vCenter FQDN: “
$ClusterName = Read-Host “Enter Cluster name of hosts that will need to be changed: “
#$trapDestination = Read-Host “SNMP Trap Mgmt server hostname: “
#$trapCommunity = Read-Host “Trap Community Name: “
$ReadOnlyCommunity = Read-Host “Read Only Community Name: “
# Running no need to change under this line
# Connect to the vCenter server
Write-Host “vCenter credentials”
$viServer = Connect-VIServer -Server $vCenterFQDN -Credential (Get-Credential)
# Get all hosts in vCenter managed Cluster so we can cycle thru them
$Hosts = Get-Cluster -Name $ClusterName | Get-VMHost
# Get ESXi Host credentials
Write-Host “ESXi host credentials”
$EsxCred = Get-Credential
# Cycle through each host
ForEach ($VMHost in $Hosts)
{
# Need to connect to ESXi itself
$esxconnect = Connect-VIServer -Server $VMHost -Credential $EsxCred
# Get snmp object
$snmpConn = Get-VMHostSnmp
# Enable snmp
Set-VMHostSnmp -HostSnmp $snmpConn -Enabled:$true
# Set read-only community
Set-VMHostSnmp -HostSnmp $snmpConn -ReadOnlyCommunity $ReadOnlyCommunity
# Set trap target host and trap community
#Set-VMHostSnmp -HostSnmp $snmpConn -AddTarget -TargetCommunity $trapCommunity -TargetHost $trapDestination
# Disconnect-VIServer
Disconnect-VIServer -Server $esxconnect -Confirm:$false
}
#disconnect from ESX server
Disconnect-VIServer -Server $viServer -Confirm:$false
# PowerCLI Script for adding syslogserver to hosts
# @mrlesmithjr
# EverythingShouldBeVirtual.com
# Change the following to match your environment
# vi_server is your vCenter
$vi_server = “p111vic01.st.com”
$vcuser = "st\admin.rb"
$vcpass = "--password--"
$communities = "public"
$syslocation = "Esx"
Connect-VIServer -Server $vi_server -User $vcuser -Password $vcpass
# Setup variable to use in script for all hosts in vCenter
$vmhosts = @(Get-VMHost)
# Configure syslog on each host in vCenter
foreach ($vmhost in $vmhosts) {
Write-Host ‘$vmhost = ‘ $vmhost
$esxcli = Get-EsxCli -VMHost $vmhost
$esxcli.system.snmp.set($null,$communities,"true",$null,$null,$null,$null,$null,$null,$null,$null,$null,$syslocation)
$esxcli.system.snmp.set($null,$communities,”$enable”)
$esxcli.system.snmp.get()
}
Disconnect-VIServer * -Confirm:$false
The Singlehost script:
#Settings$ESXHost = Read-Host “ESXi hostname to change:”$trapDestination = Read-Host “SNMP Trap Mgmt server hostname: “$trapCommunity = Read-Host “Trap Community Name: “$ReadOnlyCommunity = Read-Host “Read Only Community Name: “# Running no need to change under this line# Connect to the ESX server$viServer = Connect-VIServer -Server $ESXHost -Credential (Get-Credential)# Get snmp$snmpConn = Get-VMHostSnmp -Server $defaultViServer# Enable snmpSet-VMHostSnmp -HostSnmp $snmpConn -Enabled:$true# Set read-only communitySet-VMHostSnmp -HostSnmp $snmpConn -ReadOnlyCommunity $ReadOnlyCommunity# Set trap target and community nameSet-VMHostSnmp -HostSnmp $snmpConn -AddTarget -TargetCommunity $trapCommunity -TargetHost $trapDestination#disconnect from ESX serverDisconnect-VIServer -Server $viServer -Confirm:$false
The cluster script with a host loop:
#Settings
$vCenterFQDN = Read-Host “Enter vCenter FQDN: “
$ClusterName = Read-Host “Enter Cluster name of hosts that will need to be changed: “
#$trapDestination = Read-Host “SNMP Trap Mgmt server hostname: “
#$trapCommunity = Read-Host “Trap Community Name: “
$ReadOnlyCommunity = Read-Host “Read Only Community Name: “
# Running no need to change under this line
# Connect to the vCenter server
Write-Host “vCenter credentials”
$viServer = Connect-VIServer -Server $vCenterFQDN -Credential (Get-Credential)
# Get all hosts in vCenter managed Cluster so we can cycle thru them
$Hosts = Get-Cluster -Name $ClusterName | Get-VMHost
# Get ESXi Host credentials
Write-Host “ESXi host credentials”
$EsxCred = Get-Credential
# Cycle through each host
ForEach ($VMHost in $Hosts)
{
# Need to connect to ESXi itself
$esxconnect = Connect-VIServer -Server $VMHost -Credential $EsxCred
# Get snmp object
$snmpConn = Get-VMHostSnmp
# Enable snmp
Set-VMHostSnmp -HostSnmp $snmpConn -Enabled:$true
# Set read-only community
Set-VMHostSnmp -HostSnmp $snmpConn -ReadOnlyCommunity $ReadOnlyCommunity
# Set trap target host and trap community
#Set-VMHostSnmp -HostSnmp $snmpConn -AddTarget -TargetCommunity $trapCommunity -TargetHost $trapDestination
# Disconnect-VIServer
Disconnect-VIServer -Server $esxconnect -Confirm:$false
}
#disconnect from ESX server
Disconnect-VIServer -Server $viServer -Confirm:$false
# PowerCLI Script for adding syslogserver to hosts
# @mrlesmithjr
# EverythingShouldBeVirtual.com
# Change the following to match your environment
# vi_server is your vCenter
$vi_server = “p111vic01.st.com”
$vcuser = "st\admin.rb"
$vcpass = "--password--"
$communities = "public"
$syslocation = "Esx"
Connect-VIServer -Server $vi_server -User $vcuser -Password $vcpass
# Setup variable to use in script for all hosts in vCenter
$vmhosts = @(Get-VMHost)
# Configure syslog on each host in vCenter
foreach ($vmhost in $vmhosts) {
Write-Host ‘$vmhost = ‘ $vmhost
$esxcli = Get-EsxCli -VMHost $vmhost
$esxcli.system.snmp.set($null,$communities,"true",$null,$null,$null,$null,$null,$null,$null,$null,$null,$syslocation)
$esxcli.system.snmp.set($null,$communities,”$enable”)
$esxcli.system.snmp.get()
}
Disconnect-VIServer * -Confirm:$false
You may want to pass the credentials on the command line. I just forgot to do so
Now, the system can be queried from your LAN:
# snmpwalk -v 2c -c C0MMUN1TY esxi system SNMPv2-MIB::sysDescr.0 = STRING: VMware ESX 5.0.0 build-469512 VMware, Inc. x86_64 SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.6876.4.1 SNMPv2-MIB::sysUpTime.0 = Timeticks: (6874825) 19:05:48.25 SNMPv2-MIB::sysContact.0 = STRING: not set SNMPv2-MIB::sysName.0 = STRING: esxi.tumfatig.net SNMPv2-MIB::sysLocation.0 = STRING: not set SNMPv2-MIB::sysServices.0 = INTEGER: 72 SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00 (...)
But there is more! Try the following command:
# snmpwalk -v 2c -c C0MMUN1TY -On esxi .1.3.6.1.4.1.6876.2.1.1.8 .1.3.6.1.4.1.6876.2.1.1.8.1 = STRING: "running" .1.3.6.1.4.1.6876.2.1.1.8.2 = STRING: "notRunning" .1.3.6.1.4.1.6876.2.1.1.8.3 = STRING: "notRunning" .1.3.6.1.4.1.6876.2.1.1.8.4 = STRING: "notRunning"
Now, grab the VMware vSphere SNMP MIB Modules (VMware-esx-mibs-1.0.1-368563.zip) and install it. Then run the following command:
# snmpwalk -v 2c -c C0MMUN1TY -M +. -m ALL esxi .1.3.6.1.4.1.6876.2.1.1.8 VMWARE-VMINFO-MIB::vmwVmGuestState.1 = STRING: running VMWARE-VMINFO-MIB::vmwVmGuestState.2 = STRING: notRunning VMWARE-VMINFO-MIB::vmwVmGuestState.3 = STRING: notRunning VMWARE-VMINFO-MIB::vmwVmGuestState.4 = STRING: notRunning
Tada! This is quite simple. But there is more to get using the Perl SDK ; and maybe the vCenter… Got to figure this out… later on
BTW, it is also possible to enable SNMP from the ESXi shell. It just needs a bit of editing and services restart:
# vi /etc/vmware/snmp.xml <config><snmpSettings><enable>true</enable><communities>C0MMUN1TY</communities><targets></targets></snmpSettings></config> # services.sh restart
Monday, May 9, 2016
Vcenter Alarms ps1
#Connect to vCenter Server;
$vCenter="p111vc01.st.com"
$username="st\admin.rb"
$password=""
Connect-VIServer -Server $vCenter -Protocol https -User $username -Password $password -WarningAction SilentlyContinue | Out-Null
#Set Notification emails here;
$MailTo= "core@s$.com"
#define alarms to be set;
$actalarm1 ="Cannot connect to storage"
$actalarm2 ="Cannot find vSphere HA master agent"
$actalarm3 ="Datastore capability alarm"
$actalarm4 ="Datastore cluster is out of space"
$actalarm5 ="Datastore is in multiple datacenters"
$actalarm6 ="Datastore usage on disk"
$actalarm7 ="Exit standby error"
$actalarm8 ="Health status changed alarm"
$actalarm9 ="Health status monitoring"
$actalarm10 ="Host Baseboard Management Controller status"
$actalarm11 ="Host battery status"
$actalarm12 ="Host connection and power state"
$actalarm13 ="Host connection failure"
$actalarm14 ="Host cpu usage"
$actalarm15 ="Host error"
$actalarm16 ="Host hardware fan status"
$actalarm17 ="Host hardware power status"
$actalarm18 ="Host hardware system board status"
$actalarm19 ="Host hardware temperature status"
$actalarm20 ="Host hardware voltage"
$actalarm21 ="Host IPMI System Event Log status"
$actalarm22 ="Host memory status"
$actalarm23 ="Host memory usage"
$actalarm24 ="Host processor status"
$actalarm25 ="Host service console swap rates"
$actalarm26 ="Host storage status"
$actalarm27 ="Insufficient vSphere HA failover resources"
$actalarm28 ="License capacity monitoring"
$actalarm29 ="License error"
$actalarm30 ="License inventory monitoring"
$actalarm31 ="License user threshold monitoring"
$actalarm32 ="Migration error"
$actalarm33 ="Network connectivity lost"
$actalarm34 ="Network uplink redundancy degraded"
$actalarm35 ="Network uplink redundancy lost"
$actalarm36 ="No compatible host for Secondary VM"
$actalarm37 ="Pre-4.1 host connected to SIOC-enabled datastore"
$actalarm38 ="SRM Consistency Group Violation"
$actalarm39 ="Status of other host hardware objects"
$actalarm40 ="Storage DRS is not supported on Host."
$actalarm41 ="Storage DRS recommendation"
$actalarm42 ="The host license edition is not compatible with the vCenter Server license edition."
$actalarm43 ="Thin-provisioned volume capacity threshold exceeded."
$actalarm44 ="Timed out starting Secondary VM"
$actalarm45 ="Unmanaged workload detected on SIOC-enabled datastore"
$actalarm46 ="Virtual machine Consolidation Needed status"
$actalarm47 ="Virtual machine cpu usage"
$actalarm48 ="Virtual machine error"
$actalarm49 ="Virtual machine Fault Tolerance state changed"
$actalarm50 ="Virtual Machine Fault Tolerance vLockStep interval Status Changed"
$actalarm51 ="Virtual machine memory usage"
$actalarm52 ="VMKernel NIC not configured correctly"
$actalarm53 ="vSphere Distributed Switch MTU matched status"
$actalarm54 ="vSphere Distributed Switch MTU supported status"
$actalarm55 ="vSphere Distributed Switch teaming matched status"
$actalarm56 ="vSphere Distributed Switch vlan trunked status"
$actalarm57 ="vSphere HA failover in progress"
$actalarm58 ="vSphere HA host status"
$actalarm59 ="vSphere HA virtual machine failover failed"
$actalarm60 ="vSphere HA virtual machine monitoring action"
$actalarm61 ="vSphere HA virtual machine monitoring error"
# Delete Trigger;
Get-AlarmDefinition -Name “$actAlarm1", “$actAlarm2", “$actAlarm3", “$actAlarm4", “$actAlarm5", “$actAlarm6", “$actAlarm7", “$actAlarm8", “$actAlarm9", “$actAlarm10", “$actAlarm11", “$actAlarm12", “$actAlarm13", “$actAlarm14", “$actAlarm15", “$actAlarm16", “$actAlarm17", “$actAlarm18", “$actAlarm19", “$actAlarm20", “$actAlarm21", “$actAlarm22", “$actAlarm23", “$actAlarm24", “$actAlarm25", “$actAlarm26", “$actAlarm27", “$actAlarm28", “$actAlarm29", “$actAlarm30", “$actAlarm31", “$actAlarm32", “$actAlarm33", “$actAlarm34", “$actAlarm35", “$actAlarm36", “$actAlarm37", “$actAlarm38", “$actAlarm39",“$actAlarm40",“$actAlarm41",“$actAlarm42",“$actAlarm43",“$actAlarm44",“$actAlarm45",“$actAlarm46",“$actAlarm47",“$actAlarm48",“$actAlarm49",“$actAlarm50",“$actAlarm51",“$actAlarm52",“$actAlarm53",“$actAlarm54",“$actAlarm55",“$actAlarm56",“$actAlarm57",“$actAlarm58",“$actAlarm59",“$actAlarm60",“$actAlarm61" | Get-AlarmAction | Remove-AlarmAction -Confirm:$false
# Create Trigger;
Get-AlarmDefinition -Name “$actAlarm1", “$actAlarm2", “$actAlarm3", “$actAlarm4", “$actAlarm5", “$actAlarm6", “$actAlarm7", “$actAlarm8", “$actAlarm9", “$actAlarm10", “$actAlarm11", “$actAlarm12", “$actAlarm13", “$actAlarm14", “$actAlarm15", “$actAlarm16", “$actAlarm17", “$actAlarm18", “$actAlarm19", “$actAlarm20", “$actAlarm21", “$actAlarm22", “$actAlarm23", “$actAlarm24", “$actAlarm25", “$actAlarm26", “$actAlarm27", “$actAlarm28", “$actAlarm29", “$actAlarm30", “$actAlarm31", “$actAlarm32", “$actAlarm33", “$actAlarm34", “$actAlarm35", “$actAlarm36", “$actAlarm37", “$actAlarm38", “$actAlarm39",“$actAlarm40",“$actAlarm41",“$actAlarm42",“$actAlarm43",“$actAlarm44",“$actAlarm45",“$actAlarm46",“$actAlarm47",“$actAlarm48",“$actAlarm49",“$actAlarm50",“$actAlarm51",“$actAlarm52",“$actAlarm53",“$actAlarm54",“$actAlarm55",“$actAlarm56",“$actAlarm57",“$actAlarm58",“$actAlarm59",“$actAlarm60",“$actAlarm61" | New-AlarmAction -Email -To "$MailTo"
Get-AlarmDefinition -Name “$actAlarm1", “$actAlarm2", “$actAlarm3", “$actAlarm4", “$actAlarm5", “$actAlarm6", “$actAlarm7", “$actAlarm8", “$actAlarm9", “$actAlarm10", “$actAlarm11", “$actAlarm12", “$actAlarm13", “$actAlarm14", “$actAlarm15", “$actAlarm16", “$actAlarm17", “$actAlarm18", “$actAlarm19", “$actAlarm20", “$actAlarm21", “$actAlarm22", “$actAlarm23", “$actAlarm24", “$actAlarm25", “$actAlarm26", “$actAlarm27", “$actAlarm28", “$actAlarm29", “$actAlarm30", “$actAlarm31", “$actAlarm32", “$actAlarm33", “$actAlarm34", “$actAlarm35", “$actAlarm36", “$actAlarm37", “$actAlarm38", “$actAlarm39",“$actAlarm40",“$actAlarm41",“$actAlarm42",“$actAlarm43",“$actAlarm44",“$actAlarm45",“$actAlarm46",“$actAlarm47",“$actAlarm48",“$actAlarm49",“$actAlarm50",“$actAlarm51",“$actAlarm52",“$actAlarm53",“$actAlarm54",“$actAlarm55",“$actAlarm56",“$actAlarm57",“$actAlarm58",“$actAlarm59",“$actAlarm60",“$actAlarm61" |Get-AlarmAction | New-AlarmActionTrigger -StartStatus "Green" -EndStatus "Yellow"
Get-AlarmDefinition -Name “$actAlarm1", “$actAlarm2", “$actAlarm3", “$actAlarm4", “$actAlarm5", “$actAlarm6", “$actAlarm7", “$actAlarm8", “$actAlarm9", “$actAlarm10", “$actAlarm11", “$actAlarm12", “$actAlarm13", “$actAlarm14", “$actAlarm15", “$actAlarm16", “$actAlarm17", “$actAlarm18", “$actAlarm19", “$actAlarm20", “$actAlarm21", “$actAlarm22", “$actAlarm23", “$actAlarm24", “$actAlarm25", “$actAlarm26", “$actAlarm27", “$actAlarm28", “$actAlarm29", “$actAlarm30", “$actAlarm31", “$actAlarm32", “$actAlarm33", “$actAlarm34", “$actAlarm35", “$actAlarm36", “$actAlarm37", “$actAlarm38", “$actAlarm39",“$actAlarm40",“$actAlarm41",“$actAlarm42",“$actAlarm43",“$actAlarm44",“$actAlarm45",“$actAlarm46",“$actAlarm47",“$actAlarm48",“$actAlarm49",“$actAlarm50",“$actAlarm51",“$actAlarm52",“$actAlarm53",“$actAlarm54",“$actAlarm55",“$actAlarm56",“$actAlarm57",“$actAlarm58",“$actAlarm59",“$actAlarm60",“$actAlarm61" | Get-AlarmAction | New-AlarmActionTrigger -StartStatus "yellow" -EndStatus "green"
Get-AlarmDefinition -Name “$actAlarm1", “$actAlarm2", “$actAlarm3", “$actAlarm4", “$actAlarm5", “$actAlarm6", “$actAlarm7", “$actAlarm8", “$actAlarm9", “$actAlarm10", “$actAlarm11", “$actAlarm12", “$actAlarm13", “$actAlarm14", “$actAlarm15", “$actAlarm16", “$actAlarm17", “$actAlarm18", “$actAlarm19", “$actAlarm20", “$actAlarm21", “$actAlarm22", “$actAlarm23", “$actAlarm24", “$actAlarm25", “$actAlarm26", “$actAlarm27", “$actAlarm28", “$actAlarm29", “$actAlarm30", “$actAlarm31", “$actAlarm32", “$actAlarm33", “$actAlarm34", “$actAlarm35", “$actAlarm36", “$actAlarm37", “$actAlarm38", “$actAlarm39",“$actAlarm40",“$actAlarm41",“$actAlarm42",“$actAlarm43",“$actAlarm44",“$actAlarm45",“$actAlarm46",“$actAlarm47",“$actAlarm48",“$actAlarm49",“$actAlarm50",“$actAlarm51",“$actAlarm52",“$actAlarm53",“$actAlarm54",“$actAlarm55",“$actAlarm56",“$actAlarm57",“$actAlarm58",“$actAlarm59",“$actAlarm60",“$actAlarm61" |Get-AlarmAction | New-AlarmActionTrigger -StartStatus "red" -EndStatus "yellow"
#Disconnect from vCenter
Disconnect-VIServer -Server $vCenter -Force:$true -Confirm:$false
$vCenter="p111vc01.st.com"
$username="st\admin.rb"
$password=""
Connect-VIServer -Server $vCenter -Protocol https -User $username -Password $password -WarningAction SilentlyContinue | Out-Null
#Set Notification emails here;
$MailTo= "core@s$.com"
#define alarms to be set;
$actalarm1 ="Cannot connect to storage"
$actalarm2 ="Cannot find vSphere HA master agent"
$actalarm3 ="Datastore capability alarm"
$actalarm4 ="Datastore cluster is out of space"
$actalarm5 ="Datastore is in multiple datacenters"
$actalarm6 ="Datastore usage on disk"
$actalarm7 ="Exit standby error"
$actalarm8 ="Health status changed alarm"
$actalarm9 ="Health status monitoring"
$actalarm10 ="Host Baseboard Management Controller status"
$actalarm11 ="Host battery status"
$actalarm12 ="Host connection and power state"
$actalarm13 ="Host connection failure"
$actalarm14 ="Host cpu usage"
$actalarm15 ="Host error"
$actalarm16 ="Host hardware fan status"
$actalarm17 ="Host hardware power status"
$actalarm18 ="Host hardware system board status"
$actalarm19 ="Host hardware temperature status"
$actalarm20 ="Host hardware voltage"
$actalarm21 ="Host IPMI System Event Log status"
$actalarm22 ="Host memory status"
$actalarm23 ="Host memory usage"
$actalarm24 ="Host processor status"
$actalarm25 ="Host service console swap rates"
$actalarm26 ="Host storage status"
$actalarm27 ="Insufficient vSphere HA failover resources"
$actalarm28 ="License capacity monitoring"
$actalarm29 ="License error"
$actalarm30 ="License inventory monitoring"
$actalarm31 ="License user threshold monitoring"
$actalarm32 ="Migration error"
$actalarm33 ="Network connectivity lost"
$actalarm34 ="Network uplink redundancy degraded"
$actalarm35 ="Network uplink redundancy lost"
$actalarm36 ="No compatible host for Secondary VM"
$actalarm37 ="Pre-4.1 host connected to SIOC-enabled datastore"
$actalarm38 ="SRM Consistency Group Violation"
$actalarm39 ="Status of other host hardware objects"
$actalarm40 ="Storage DRS is not supported on Host."
$actalarm41 ="Storage DRS recommendation"
$actalarm42 ="The host license edition is not compatible with the vCenter Server license edition."
$actalarm43 ="Thin-provisioned volume capacity threshold exceeded."
$actalarm44 ="Timed out starting Secondary VM"
$actalarm45 ="Unmanaged workload detected on SIOC-enabled datastore"
$actalarm46 ="Virtual machine Consolidation Needed status"
$actalarm47 ="Virtual machine cpu usage"
$actalarm48 ="Virtual machine error"
$actalarm49 ="Virtual machine Fault Tolerance state changed"
$actalarm50 ="Virtual Machine Fault Tolerance vLockStep interval Status Changed"
$actalarm51 ="Virtual machine memory usage"
$actalarm52 ="VMKernel NIC not configured correctly"
$actalarm53 ="vSphere Distributed Switch MTU matched status"
$actalarm54 ="vSphere Distributed Switch MTU supported status"
$actalarm55 ="vSphere Distributed Switch teaming matched status"
$actalarm56 ="vSphere Distributed Switch vlan trunked status"
$actalarm57 ="vSphere HA failover in progress"
$actalarm58 ="vSphere HA host status"
$actalarm59 ="vSphere HA virtual machine failover failed"
$actalarm60 ="vSphere HA virtual machine monitoring action"
$actalarm61 ="vSphere HA virtual machine monitoring error"
# Delete Trigger;
Get-AlarmDefinition -Name “$actAlarm1", “$actAlarm2", “$actAlarm3", “$actAlarm4", “$actAlarm5", “$actAlarm6", “$actAlarm7", “$actAlarm8", “$actAlarm9", “$actAlarm10", “$actAlarm11", “$actAlarm12", “$actAlarm13", “$actAlarm14", “$actAlarm15", “$actAlarm16", “$actAlarm17", “$actAlarm18", “$actAlarm19", “$actAlarm20", “$actAlarm21", “$actAlarm22", “$actAlarm23", “$actAlarm24", “$actAlarm25", “$actAlarm26", “$actAlarm27", “$actAlarm28", “$actAlarm29", “$actAlarm30", “$actAlarm31", “$actAlarm32", “$actAlarm33", “$actAlarm34", “$actAlarm35", “$actAlarm36", “$actAlarm37", “$actAlarm38", “$actAlarm39",“$actAlarm40",“$actAlarm41",“$actAlarm42",“$actAlarm43",“$actAlarm44",“$actAlarm45",“$actAlarm46",“$actAlarm47",“$actAlarm48",“$actAlarm49",“$actAlarm50",“$actAlarm51",“$actAlarm52",“$actAlarm53",“$actAlarm54",“$actAlarm55",“$actAlarm56",“$actAlarm57",“$actAlarm58",“$actAlarm59",“$actAlarm60",“$actAlarm61" | Get-AlarmAction | Remove-AlarmAction -Confirm:$false
# Create Trigger;
Get-AlarmDefinition -Name “$actAlarm1", “$actAlarm2", “$actAlarm3", “$actAlarm4", “$actAlarm5", “$actAlarm6", “$actAlarm7", “$actAlarm8", “$actAlarm9", “$actAlarm10", “$actAlarm11", “$actAlarm12", “$actAlarm13", “$actAlarm14", “$actAlarm15", “$actAlarm16", “$actAlarm17", “$actAlarm18", “$actAlarm19", “$actAlarm20", “$actAlarm21", “$actAlarm22", “$actAlarm23", “$actAlarm24", “$actAlarm25", “$actAlarm26", “$actAlarm27", “$actAlarm28", “$actAlarm29", “$actAlarm30", “$actAlarm31", “$actAlarm32", “$actAlarm33", “$actAlarm34", “$actAlarm35", “$actAlarm36", “$actAlarm37", “$actAlarm38", “$actAlarm39",“$actAlarm40",“$actAlarm41",“$actAlarm42",“$actAlarm43",“$actAlarm44",“$actAlarm45",“$actAlarm46",“$actAlarm47",“$actAlarm48",“$actAlarm49",“$actAlarm50",“$actAlarm51",“$actAlarm52",“$actAlarm53",“$actAlarm54",“$actAlarm55",“$actAlarm56",“$actAlarm57",“$actAlarm58",“$actAlarm59",“$actAlarm60",“$actAlarm61" | New-AlarmAction -Email -To "$MailTo"
Get-AlarmDefinition -Name “$actAlarm1", “$actAlarm2", “$actAlarm3", “$actAlarm4", “$actAlarm5", “$actAlarm6", “$actAlarm7", “$actAlarm8", “$actAlarm9", “$actAlarm10", “$actAlarm11", “$actAlarm12", “$actAlarm13", “$actAlarm14", “$actAlarm15", “$actAlarm16", “$actAlarm17", “$actAlarm18", “$actAlarm19", “$actAlarm20", “$actAlarm21", “$actAlarm22", “$actAlarm23", “$actAlarm24", “$actAlarm25", “$actAlarm26", “$actAlarm27", “$actAlarm28", “$actAlarm29", “$actAlarm30", “$actAlarm31", “$actAlarm32", “$actAlarm33", “$actAlarm34", “$actAlarm35", “$actAlarm36", “$actAlarm37", “$actAlarm38", “$actAlarm39",“$actAlarm40",“$actAlarm41",“$actAlarm42",“$actAlarm43",“$actAlarm44",“$actAlarm45",“$actAlarm46",“$actAlarm47",“$actAlarm48",“$actAlarm49",“$actAlarm50",“$actAlarm51",“$actAlarm52",“$actAlarm53",“$actAlarm54",“$actAlarm55",“$actAlarm56",“$actAlarm57",“$actAlarm58",“$actAlarm59",“$actAlarm60",“$actAlarm61" |Get-AlarmAction | New-AlarmActionTrigger -StartStatus "Green" -EndStatus "Yellow"
Get-AlarmDefinition -Name “$actAlarm1", “$actAlarm2", “$actAlarm3", “$actAlarm4", “$actAlarm5", “$actAlarm6", “$actAlarm7", “$actAlarm8", “$actAlarm9", “$actAlarm10", “$actAlarm11", “$actAlarm12", “$actAlarm13", “$actAlarm14", “$actAlarm15", “$actAlarm16", “$actAlarm17", “$actAlarm18", “$actAlarm19", “$actAlarm20", “$actAlarm21", “$actAlarm22", “$actAlarm23", “$actAlarm24", “$actAlarm25", “$actAlarm26", “$actAlarm27", “$actAlarm28", “$actAlarm29", “$actAlarm30", “$actAlarm31", “$actAlarm32", “$actAlarm33", “$actAlarm34", “$actAlarm35", “$actAlarm36", “$actAlarm37", “$actAlarm38", “$actAlarm39",“$actAlarm40",“$actAlarm41",“$actAlarm42",“$actAlarm43",“$actAlarm44",“$actAlarm45",“$actAlarm46",“$actAlarm47",“$actAlarm48",“$actAlarm49",“$actAlarm50",“$actAlarm51",“$actAlarm52",“$actAlarm53",“$actAlarm54",“$actAlarm55",“$actAlarm56",“$actAlarm57",“$actAlarm58",“$actAlarm59",“$actAlarm60",“$actAlarm61" | Get-AlarmAction | New-AlarmActionTrigger -StartStatus "yellow" -EndStatus "green"
Get-AlarmDefinition -Name “$actAlarm1", “$actAlarm2", “$actAlarm3", “$actAlarm4", “$actAlarm5", “$actAlarm6", “$actAlarm7", “$actAlarm8", “$actAlarm9", “$actAlarm10", “$actAlarm11", “$actAlarm12", “$actAlarm13", “$actAlarm14", “$actAlarm15", “$actAlarm16", “$actAlarm17", “$actAlarm18", “$actAlarm19", “$actAlarm20", “$actAlarm21", “$actAlarm22", “$actAlarm23", “$actAlarm24", “$actAlarm25", “$actAlarm26", “$actAlarm27", “$actAlarm28", “$actAlarm29", “$actAlarm30", “$actAlarm31", “$actAlarm32", “$actAlarm33", “$actAlarm34", “$actAlarm35", “$actAlarm36", “$actAlarm37", “$actAlarm38", “$actAlarm39",“$actAlarm40",“$actAlarm41",“$actAlarm42",“$actAlarm43",“$actAlarm44",“$actAlarm45",“$actAlarm46",“$actAlarm47",“$actAlarm48",“$actAlarm49",“$actAlarm50",“$actAlarm51",“$actAlarm52",“$actAlarm53",“$actAlarm54",“$actAlarm55",“$actAlarm56",“$actAlarm57",“$actAlarm58",“$actAlarm59",“$actAlarm60",“$actAlarm61" |Get-AlarmAction | New-AlarmActionTrigger -StartStatus "red" -EndStatus "yellow"
#Disconnect from vCenter
Disconnect-VIServer -Server $vCenter -Force:$true -Confirm:$false
Vmware NFS PowerCli
get-cluster QA-DEV | get-VMhost | -NFS -Name NexsanStore05 -Path /pools/Pool2/DataStore05 -nfshost 10.25.28.14
get-cluster QA-DEV | get-VMhost | -NFS -Name NexsanStore05 -Path /pools/Pool2/DataStore05 -nfshost 10.25.28.14
get-cluster QA-DEV | get-VMhost | New-Datastore -NFS -Name NexsanStore05 -Path /pools/Pool2/DataStore05 -nfshost 10.25.28.14
get-VMhost iad-esx-ucs1-04.st.com | New-Datastore -NFS -Name NexsanStore01 -Path /pools/NexsanPool1/DataStore01 -nfshost 10.25.28.13
get-VMhost iad-esx-ucs1-04.st.com | New-Datastore -NFS -Name NexsanStore02 -Path /pools/NexsanPool1/DataStore02 -nfshost 10.25.28.13
get-VMhost iad-esx-ucs1-04.st.com | New-Datastore -NFS -Name NexsanStore03 -Path /pools/NexsanPool1/DataStore03 -nfshost 10.25.28.13
get-VMhost iad-esx-ucs1-04.st.com | New-Datastore -NFS -Name NexsanStore04 -Path /pools/NexsanPool1/DataStore04 -nfshost 10.25.28.13
get-VMhost iad-esx-ucs1-04.st.com | New-Datastore -NFS -Name NexsanStore05 -Path /pools/Pool2/DataStore05 -nfshost 10.25.28.14
get-cluster QA-DEV | get-VMhost | -NFS -Name NexsanStore05 -Path /pools/Pool2/DataStore05 -nfshost 10.25.28.14
get-cluster QA-DEV | get-VMhost | New-Datastore -NFS -Name NexsanStore05 -Path /pools/Pool2/DataStore05 -nfshost 10.25.28.14
get-VMhost iad-esx-ucs1-04.st.com | New-Datastore -NFS -Name NexsanStore01 -Path /pools/NexsanPool1/DataStore01 -nfshost 10.25.28.13
get-VMhost iad-esx-ucs1-04.st.com | New-Datastore -NFS -Name NexsanStore02 -Path /pools/NexsanPool1/DataStore02 -nfshost 10.25.28.13
get-VMhost iad-esx-ucs1-04.st.com | New-Datastore -NFS -Name NexsanStore03 -Path /pools/NexsanPool1/DataStore03 -nfshost 10.25.28.13
get-VMhost iad-esx-ucs1-04.st.com | New-Datastore -NFS -Name NexsanStore04 -Path /pools/NexsanPool1/DataStore04 -nfshost 10.25.28.13
get-VMhost iad-esx-ucs1-04.st.com | New-Datastore -NFS -Name NexsanStore05 -Path /pools/Pool2/DataStore05 -nfshost 10.25.28.14
Windows Failover Cluster Migration with vSphere Replication
Windows Failover Cluster Migration with vSphere Replication
http://vmnomad.blogspot.com/2015/09/windows-failover-cluster-migration-with.html
Switch RDM disks to virtual compatibility mode - VMware KB106599
Rexplicate one MSCS node and all RDM disks to pre-created virtual RDM disk at the destination datacenter.
Replicate the rest of the WFC nodes with OS disks only.
Switch RDM back to physical mode at the destination datacenter
Connect all RDM disks back to the MSCS nodes
Then it was time to do a actual test. I have pretty small home lab so I had to replicate the WFC between ESXi hosts in the same cluster.
Complete the prerequisites
Prepare the port-groups, e.g. data and heartbeat networks for WFC cluster
Write down the specs of the LUNs used by WFC and provision the same size LUNs at the destination site. The LUN numbers don't have to match.
http://vmnomad.blogspot.com/2015/09/windows-failover-cluster-migration-with.html
Switch RDM disks to virtual compatibility mode - VMware KB106599
Rexplicate one MSCS node and all RDM disks to pre-created virtual RDM disk at the destination datacenter.
Replicate the rest of the WFC nodes with OS disks only.
Switch RDM back to physical mode at the destination datacenter
Connect all RDM disks back to the MSCS nodes
Then it was time to do a actual test. I have pretty small home lab so I had to replicate the WFC between ESXi hosts in the same cluster.
Complete the prerequisites
Prepare the port-groups, e.g. data and heartbeat networks for WFC cluster
Write down the specs of the LUNs used by WFC and provision the same size LUNs at the destination site. The LUN numbers don't have to match.
Automatic virtual hardware change after shutdown – vCenter alarms and #PowerCLI
Vmware folder actions
Teaching an Optimize and Scale class this week I was asked if there is chance to automatically change the virtual hardware once a VM has been shut down or powered off.
Scenario – Customer wants to change the CPU / RAM of their XenDesktops with minimal impact on the end-user. If a VM is powered off vCenter should change the hardware and wait until another components powers the VM on again.
At first I was not sure how this can be done. Using PowerCLI for changing the virtual hardware? – easy… but how can we call this script once the VM is powered off? After a minute I remebered that we can use vCenter alarms to trigger more than just snmp/email actions if a specific Event/Condition occurs. We can also run cmds and therefore call a PowerCLI script.
Requirements:
Using AD-based authentication for the PowerCLI script makes it easier regarding the Authentication mechanism. Therefore the vCenter server must run with Active Directory Service Account that has the proper permissions on the vCenter level
Chapter 1: Easy going – Hardcode the CPU count in the script
Create the PowerCLI script
Now we create the modify-cpu.ps1 script that will be stored in the C:\scripts\
with the following content. (Note: the CPU count must be hardcoded in the script by changing the $numCPU parameter. Be aware of that this script changes the count of Cores and stays with 1 virtual socket.
Complete Script – modify-cpu.ps1:
Create the vCenter alarm that will call the script above with the VM name as parameter
Select the VM you want the virtual CPU count be changed after a shutdown and create a vCenter alarm (wow I am really using the webclient)
Give it a valuable name and describiton and select to monitor for a specific event
As an event where the alarm and therefore the action will be triggered we select VM – Powered off
And finally as an action we call our created PowerCLI script in C:\scripts with the following statement:
“c:\windows\system32\cmd.exe” “/c echo.|powershell.exe -nologo -noprofile -noninteractive C:\scripts\modify-cpu.ps1 {targetName}”
With the {targetName} variable we can transfer the name of the virtual machine that caused the Trigger.
And voila. If the VM is now getting powered-off -> the change of the virtual hardware will be done.
(German language, hm!? Doesn’t sound it quiet nice :P)
If the configuration is not working as expected, validate the functionality by call cmd with the user that is running the vCenter service:
> Open CMD
> runas /user:Domain\vCenteruser cmd
> “c:\windows\system32\cmd.exe” “/c echo.|powershell.exe -nologo -noprofile -noninteractive C:\scripts\modify-hardware.ps1 {targetName}”
Chapter 2: Make it more awesome by using VMs and Templates Folders
To be more flexible on the hardware configuration I wanted to have the following functionality:
Drag and Drop a VM in a specific folder. If the VM is powered off change the virtual hardware based on specific settings. The settings should be extracted from the folder name.
Foldername specification: modify_ressourcetype_value
for example I create 4 Folders:
So I needed to change my script in a way that it gathers the folder the of the VM that is transmitted with the script call:
Complete Script – modify-hardware.ps1:
Transfer the following modify-hardware.ps1 script into C:\scripts\ and configure this time the alarms in the same way as described above – but now on the specific folder we have created for this solution.
The action call this time needs to be renamed since I created another script:
“c:\windows\system32\cmd.exe” “/c echo.|powershell.exe -nologo -noprofile -noninteractive C:\scripts\modify-hardware.ps1 {targetName}”
Complete Script – modify-hardware.ps1:
Scenario – Customer wants to change the CPU / RAM of their XenDesktops with minimal impact on the end-user. If a VM is powered off vCenter should change the hardware and wait until another components powers the VM on again.
At first I was not sure how this can be done. Using PowerCLI for changing the virtual hardware? – easy… but how can we call this script once the VM is powered off? After a minute I remebered that we can use vCenter alarms to trigger more than just snmp/email actions if a specific Event/Condition occurs. We can also run cmds and therefore call a PowerCLI script.
Requirements:
Using AD-based authentication for the PowerCLI script makes it easier regarding the Authentication mechanism. Therefore the vCenter server must run with Active Directory Service Account that has the proper permissions on the vCenter level
Chapter 1: Easy going – Hardcode the CPU count in the script
Create the PowerCLI script
Now we create the modify-cpu.ps1 script that will be stored in the C:\scripts\
with the following content. (Note: the CPU count must be hardcoded in the script by changing the $numCPU parameter. Be aware of that this script changes the count of Cores and stays with 1 virtual socket.
Complete Script – modify-cpu.ps1:
param( [string]$vmname ) $vCenter = 'localhost' $numCPU = 4 #### # Include VMware-PowerCLI SnapIn if(!(Get-PSSnapin | Where {$_.name -eq "vmware.vimautomation.core"})) { try { Write-Host "Adding PowerCLI snap in" Add-PSSnapin VMware.VimAutomation.Core -ea 0| out-null } catch { throw "Could not load PowerCLI snapin" } } Connect-VIServer $vCenter $vm = get-vm $vmname $spec=New-Object –Type VMware.Vim.VirtualMAchineConfigSpec –Property @{"NumCoresPerSocket" = $numCPU;"numCPUs" = $numCPU} $vm.ExtensionData.ReconfigVM_Task($spec) | out-null Disconnect-VIServer $vCenter -confirm:$false
Create the vCenter alarm that will call the script above with the VM name as parameter
Select the VM you want the virtual CPU count be changed after a shutdown and create a vCenter alarm (wow I am really using the webclient)
Give it a valuable name and describiton and select to monitor for a specific event
As an event where the alarm and therefore the action will be triggered we select VM – Powered off
And finally as an action we call our created PowerCLI script in C:\scripts with the following statement:
“c:\windows\system32\cmd.exe” “/c echo.|powershell.exe -nologo -noprofile -noninteractive C:\scripts\modify-cpu.ps1 {targetName}”
With the {targetName} variable we can transfer the name of the virtual machine that caused the Trigger.
And voila. If the VM is now getting powered-off -> the change of the virtual hardware will be done.
(German language, hm!? Doesn’t sound it quiet nice :P)
If the configuration is not working as expected, validate the functionality by call cmd with the user that is running the vCenter service:
> Open CMD
> runas /user:Domain\vCenteruser cmd
> “c:\windows\system32\cmd.exe” “/c echo.|powershell.exe -nologo -noprofile -noninteractive C:\scripts\modify-hardware.ps1 {targetName}”
Chapter 2: Make it more awesome by using VMs and Templates Folders
To be more flexible on the hardware configuration I wanted to have the following functionality:
Drag and Drop a VM in a specific folder. If the VM is powered off change the virtual hardware based on specific settings. The settings should be extracted from the folder name.
Foldername specification: modify_ressourcetype_value
for example I create 4 Folders:
- modify_cpu_2
- modify_cpu_4
- modify_ram_4
- modify_ram_8
So I needed to change my script in a way that it gathers the folder the of the VM that is transmitted with the script call:
Complete Script – modify-hardware.ps1:
$vm = get-vm $vmname $vmFolderName = $vm.Folder.Nameand split the foldername at the ‘_’ chars:
$items = $vmFolderName.Split('_') $ressourceType = $items[1] $amount = $items[2]Now I can select the change RAM or CPU logic with a ‘switch’ statement:
switch($ressourceType){ 'cpu' { $vCPu= $amount $spec=New-Object –Type VMware.Vim.VirtualMAchineConfigSpec –Property @{"NumCoresPerSocket" = $vCPu;"numCPUs" = $vCPu} $vm.ExtensionData.ReconfigVM_Task($spec) | out-null } 'ram' { $NmbrRam = $amount set-vm -VM $vm -memoryGb $NmbrRam -confirm:$false } default { write-verbose 'Wrong folder name specification' } }If the VM is not in a folder that matches the specification. Nothing will happen.
Transfer the following modify-hardware.ps1 script into C:\scripts\ and configure this time the alarms in the same way as described above – but now on the specific folder we have created for this solution.
The action call this time needs to be renamed since I created another script:
“c:\windows\system32\cmd.exe” “/c echo.|powershell.exe -nologo -noprofile -noninteractive C:\scripts\modify-hardware.ps1 {targetName}”
Complete Script – modify-hardware.ps1:
param( [string]$vmname ) $vCenter = 'localhost' ### # Include VMware-PowerCLI SnapIn if(!(Get-PSSnapin | Where {$_.name -eq "vmware.vimautomation.core"})) { try { Write-Host "Adding PowerCLI snap in" Add-PSSnapin VMware.VimAutomation.Core -ea 0| out-null } catch { throw "Could not load PowerCLI snapin" } } Connect-VIServer $vCenter #Gather Objects and Data $vm = get-vm $vmname $vmFolderName = $vm.Folder.Name #Split the folder name to extract parameter - Foldername must be modify_ressource_x #while ressource must be ram or cpu and X the number of CPU or amount of RAM in GB $items = $vmFolderName.Split('_') $ressourceType = $items[1] $amount = $items[2] $items switch($ressourceType){ 'cpu' { $vCPu= $amount $spec=New-Object –Type VMware.Vim.VirtualMAchineConfigSpec –Property @{"NumCoresPerSocket" = $vCPu;"numCPUs" = $vCPu} $vm.ExtensionData.ReconfigVM_Task($spec) | out-null } 'ram' { $NmbrRam = $amount set-vm -VM $vm -memoryGb $NmbrRam -confirm:$false } default { write-verbose 'Wrong folder name specification' } } Disconnect-ViServer $vCenter -confirm:$falseMaybe some of you will benefit from this little script-collection. Have fun with it
Why learn VMware #PowerCLI
PowerCLI (based on Powershell) is one of those things that really boosted my productivity in the VMware field. It is an easy to use product that allows you to do incredible things within a vSphere… wait… VMware environment (it also includes cmdlets for vCloud, vRealize, View …. ). Do bulk operations? easy-as-that… Gather some data for reports? not-a-big-problem-at all… Delivering hot coffee to your desk? Okok… not that incredible things (yet)…
Nowadays I still meet so many people during my daily business that aren’t really into it or are kind of afraid of using Powershell/PowerCLI. Let me try to give you some arguments why learning PowerCLI is a great idea even though it’s principles are kind of / come close to ‘programming’ *WE-HATE-PROGRAMMING-ANGST*.
Nowadays I still meet so many people during my daily business that aren’t really into it or are kind of afraid of using Powershell/PowerCLI. Let me try to give you some arguments why learning PowerCLI is a great idea even though it’s principles are kind of / come close to ‘programming’ *WE-HATE-PROGRAMMING-ANGST*.
1.) Become a better admin / consultant (and even architect)
As an admin (especially from the windows world) we as administrators spent so much time configuring stuff multiple times. Doing it in a graphical user mouse-/pointer-based interface it might not just take a long time. To enable SSH on 5 ESXi hosts it would take you including the login to the webclient incredible many clicks (In the 5 hosts scenario you probably need 35 clicks, 0,3 meters of scrolling, 142 seconds in the web client).
How do we solve it with PowerCLI?
Get-VMHost | Get-VMhostService | Where-Object {$_.Key -eq “TSM-SSH”} | Start-VMHostService
Much easier, especially if you archive your helper scripts somewhere so you can re-use them when ever there is a need (I know my Github repository is small, but it’s growing)
2.) Easy to learn – hard to master
The best way to describe PowerCLI / Powershell is by comparing it with Mario Kart. One of the best (and funny) video games the world has ever seen. Why is it so? Because it is so easy to get started with that even beginners might win with a little bit of luck. But anyway, if you want to start to reach maximum goals you will realise that there is so much you can do better.
The same is applicable with PowerCLI. Instead of getting a lame ‘hello world’ output in the beginning you can really create something you are familiar with (VMs, gathering useful data, etc.).
BUT remember… Mario Kart is a game… if you lose, you lose and start all over again… In the real life you would not want to go the racetrack as a beginner and start throwing bananas at other cars (at least I hope you wouldn’t do that). Learn and increase your PowerCLI skills in test-environments and only go with it into production if you understand the impact/risk and functionality of the scripts you are using.
One-liners like Get-VM | Stop-VM can create huge service impacts within your environment with minimum effort.
3.) Getting familiar with programmatical and automation approaches
The datacenter is getting more and more complex. Every component is getting abstracted multiple times ending up in a api-programmable resource. This creates new challenges (complexity) but gives us new opportunities in forms of service delivery speed / automation. In the future it will become more and more important that proccesses/workflows needs to be created (and maintained). And no matter how you are going to implement it (Orchestrator, Powershell, etc.) – the logical way of achieving it is always the same and always related to approaches coming from the programming field.
Learning PowerCLI means getting familiar with those approaches. You need to know why we need if-/else-/switch statements. Why do we need loops. What are datatypes. What is the reason that object-oriented thinking is so valuable.
Powershell (and therefore PowerCLI) abstracts away much of the mentioned complexity, but you will still touch them from time to time. Therefore if you are curious you will get a much deeper insight every time you confront yourself with those topics.
Once you are familiar with how to logically automate specific workflows (because you created your own automation mechanisms), you don’t really care which solution the automation does.
4.) The PowerCLI community is one of the best I have seen in the tech-field
There is nothing more to say. For almost every problem someone has already created a solution and has posted it in a blog / board. So what to do? Google for PowerCLI <What you want to achieve>, e.g. PowerCLI get vCPU in a cluster
in 95% of the cases you will find a suitable solution (maybe you need to edit the final script a little bit) on the first page of google.
And if you don’t find a solution. Just post them to the official VMware PowerCLI community
p.s. In 4 out of 5 posts Luc Dekens will help you within 72 seconds after you have posted a question there. This guy brings so much value to the PowerCLI community. Thanks for that.
5.) For nearly every problem a script or a snippet is already available
<If you have just read passage 4) too quickly…. you should read it in more detail now >
6.) PowerCLI forces you to work more accurate
Yes PowerCLI is pretty easy, but it is also a text-based user interaction. And it’s pretty typical if you configure something via text that you need to know for 100% what you are doing (in GUIs you can more easily have a trial- and error click experience).
Planning in advance what are you going to do & having a powerful tool at your hand that can shutdown your whole environment within seconds will force you to work more accurate and think more ahead in your daily doing. A skill that is IMO very very important.
Always remember what the uncle of a good’s friend’s friend told some guy:
“With great Power(CLI) comes great responsibility”
Best practices for using and troubleshooting VMware Converter (1004588)
Symptoms
- No keyboard or mouse in a converted virtual machine
- You see one of these messages in an error dialog:
Unknown error returned by VMware Converter Agent
Out of disk space
- You see one of these messages in a VMware Converter log file:
Failed to establish Vim connection
Import host not found
P2VError UFAD_SYSTEM_ERROR(Internal Error)
Pcopy_CloneTree failed with err=80
The file exists (80)
Failed to connect
Giving up trying to connect
Failed to take snapshot of the source volume
stcbasic.sys not installed or snapshot creation failed. err=2
Can't create undo folder
sysimage.fault.FileCreateError
sysimage.fault.ReconfigFault
sysimage.fault.PlatformError
Number of virtual devices exceeds maximum for a given controller
TooManyDevices
QueryDosDevice: ret=270 size=1024 err=0
Error opening disk device: Incorrect function (1)
Vsnap does not have admin rights
Specified key identifier already exists
vim.fault.NoDiskSpac
Purpose
This article describes various best practice techniques that can be followed to minimize potential problems when using the VMware Converter product.
Take note of the procedures outlined in this article. While not all steps may apply to your situation, if one of the steps in the article is different from what you had followed in your environment, attempt another conversion after changing your procedure to follow the recommendation in that step.
Resolution
These steps are not a recommendation against using certain features of VMware Converter in normal use, but are a guide to assist in troubleshooting general failures with Converter.
If you encounter a specific failure, open the Converter log file, identify the failure message near the end of the log file and perform a search in the VMware Knowledge Base for more detailed assistance on the issue.
The best approach to converting a Windows operating system to a virtual machine is to perform a hot migration with VMware Converter installed locally in the operating system. If this is not possible, a remote hot migration is the next best choice.
Download Converter from the VMware Download Center.
Note: Currently, only VMware Converter 4.2 and later support physical to virtual machine conversion for Linux sources. For earlier versions of Converter, the support is experimental and some of the features, such as partition resizing, are not available.
Notes and preparation for conversion
To prepare for conversion:
- If the source is a domain controller, special considerations must be made. VMware does not recommend virtualizing an active domain controller with Converter. For more information, see Virtualizing existing domain controllers (1006996).
- If the source is Microsoft Exchange, SQL, or other database server, VMware recommends that the application (Microsoft Exchange/SQL) and database services be shut down prior to conversion. This minimizes any chance of corrupted database tables or stale data in the destination virtual machine.
- Disable the real-time antivirus scanning during the conversion.
- Read the VMware Converter Release Notes. The release notes review important limitations or issues that may affect the conversion process.
- Verify that you are using or have downloaded the latest version of VMware Converter.
If you have previously installed or attempted a conversion with an earlier version of VMware Converter, a previous version may still be installed.- Uninstall VMware Converter from the source computer:
- Click Start > Control Panel > Add / Remove Programs or Programs and Features depending on the Operating System.
- Uninstall any version of VMware Converter, Converter agent, or Converter Enterprise.
- Restart the server.
- Install the latest version of VMware Converter using the local Administrator account. If you are going to use the remote hot clone feature you may choose a custom installation to only install the Converter Agent.
- If the server is running Windows 2000 or Windows NT, you must restart the server or Converter does not start.
- Uninstall VMware Converter from the source computer:
- Install VMware Converter directly to the source operating system using the local Administrator account. If the source server is running Windows NT or Windows 2000, you must reboot it after installing VMware Converter or Converter does not start.
Note: In some cases, a domain administrator account may be used depending on your environment, local and group policies, and account permissions. - If the NIC on the source machine is compatible with TOE (TCP Offload Engine), you need to disable it by running this command in a command prompt on the source machine:
netsh int tcp set global chimney=disabled
For additional information, see the Microsoft Knowledge Base article 951037.
Note: The preceding link was correct as of November 21, 2014. If you find the link is broken, provide feedback and a VMware employee will update the link. - Confirm that the source has 200 MB of free disk space on its system volume. This space is required to operate the disk snapshot features in Converter. For more information, see Investigating operating system disk space (1004007).
Note: It is possible to separate the source partitions in different destination volumes during the conversion. - Run VMware Converter as a local administrator. Using a local administrator account removes any possible permissions issues. If you are performing a remote conversion, be sure to specify the login user as the Administrator account.
Note: In some cases a domain administrator account may be used depending on your environment, local and group policies, and account permissions. - Run the System Configuration Utility
(msconfig)
on the source server to reduce the number of services and applications running on startup, all software except for All Microsoft Services and VMware Converter Service. For more information, see Using the Windows System Configuration utility (1004010). - If you have static IP addresses assigned, assign the interfaces DHCP addresses prior to conversion, if possible.
- If the source is a virtual machine created in Microsoft Virtual PC, remove the Virtual PC Additions, prior to conversion.
- If the destination is an ESX host:
- Connect to the server using its IP address instead of DNS host name. Using the host name of the ESX host may expose issues with DNS name resolution that can prevent the Converter from connecting.
- Confirm that the source server can access the destination ESX host directly using ports 443 and 902, even if using VirtualCenter. For more information, see Verifying and troubleshooting networking connections that may cause VMware Converter to fail (1006607).
- Authenticate to the ESX host using the
root
account. - If the source server contains a hard drive or partition larger than 256GB, ensure that the destination datastore's block size is 2MB, 4MB, or 8MB, and not the default 1MB size. The 1 MB default block size cannot accommodate a file larger than 256 GB. The block size is no longer used on a VMFS 5 datastore connected to an ESXi 5.0 Host.
- Confirm that you are providing a unique name for the target virtual machine. Use the Virtual Infrastructure (VI) client to confirm that the name is not already in use.
Optimizing the conversion for best success
To set up conversion for the best success:
If you are encountering failures with Converter, reduce the number of optional items in the Conversion Wizard:
- Do not convert diagnostic partitions or unrecognized file systems.
- If you are experiencing cloning phase failures, do not choose to resize the partitions.
- If there are multiple volumes, attempt converting only the system volume.
- If you are experiencing network or Ethernet issues, trying using a different network type. For more information, see Understanding networking types in hosted products (1006480).
- Leave the default number of virtual network cards (NICs) unaltered. The number of virtual NICs can be changed after conversion has completed.
- Deselect the option to install VMware Tools.
- Deselect the option to perform Customization on the virtual machine.
Tasks to perform after conversion has completed
After conversion has completed:
- Review the virtual hardware settings:
- Adjust the number of virtual NICs. If you need to customize the host name or IP address, leave all NICs disconnected but present.
- Remove any unnecessary devices such as USB controllers (if running on ESX), COM ports or floppy drives
- Start the virtual machine in Safe Mode. For more information, see Booting a Windows guest operating system into Safe Mode (1004011).
- Click Start > Control Panel > Add / Remove Programs. Remove any unnecessary programs used to install or support device drivers, such a RAID management tools, network teaming or management software, wireless card management software, and video and sound drivers. Do not restart if prompted by an uninstall program.
- Restart the virtual machine into Normal mode.
- Remove any additional devices or device drivers that were used to support hardware on the physical server. Use either the Device Manager or Control Panel, depending on the version of Windows, to remove unnecessary devices. It may also be necessary to view the Event Log to clear any remaining device startup failure messages.
Note: To remove the hidden devices from the Windows operating system, follow the instructions in the Microsoft Knowledge Base article 315539.
Note: The preceding link was correct as of November 21, 2014. If you find the link is broken, provide feedback and a VMware employee will update the link. - VMware recommends changing the HAL in the virtual machine to uniprocessor if the source server is configured with multi-CPU hardware abstraction layer (HAL), and the destination virtual machine is configured to use a single CPU. For more information, seeModifying the Hardware Abstraction Layer (HAL) for a Windows virtual machine (1003978).
- Install VMware Tools and restart if prompted.
- If required, customize the virtual machine's identity. VMware recommends using the Microsoft Sysprep utility to accomplish this, however it can also be accomplished by manually changing its computer host name, IP address, and any other required unique identification. For more information, see Microsoft's article How to Use Sysprep: An Introduction.
Note: The preceding link was correct as of November 21, 2014. If you find the link is broken, provide feedback and a VMware employee will update the link. - If the System Configuration Utility
(msconfig)
was used prior to conversion, select the Normal startup option to change switch back to a normal boot configuration. For more information, see Using the Windows System Configuration utility (1004010). - Apply any previously removed static IP address settings, as required.
- Reconnect any disconnected virtual NICs, as required.
Subscribe to:
Posts (Atom)
Vmware NSX SSL creation
Using OpenSSL for NSX Manager SSL import: Creates CSR and 4096 bit KEY Creating NSX 6.4.2 SSL openssl req -out nsxcert.csr -newkey rsa:40...
-
vmware converter – p2v – partition number must be set for the boot volume Leave a reply I was trying to archive old machine running R...
-
root@vcsa1 [ ~ ]# service-control –stop –all Perform stop operation. vmon_profile=ALL, svc_names=None, include_coreossvcs=True, i...
-
Adding a TCP/IP stack esxcli network ip netstack add -N "NFS" If vmkernal was pre-create then you will need to delete and...