Thursday, April 28, 2016

VM Won't Shutdown / Script to kill a hung vCenter task | VMware Communities

Script to kill a hung vCenter task | VMware Communities


If a VM can't be shut down or restarted because of "Another task is in progress" messages, here's a method to kill the VM:


SSH must be enabled on the host so you can SSH in. Alternatively, this can be done using PowerCLI, but I need to look up the commands.

esxcli vm process list

This displays a list of all the running VMs. You need to find the World ID of the VM that is stuck. Example:

ATL-FILE-01
   World ID: 5466595
   Process ID: 0
   VMX Cartel ID: 5466592
   UUID: 42 1b c8 64 36 2f 9d 94-d2 0e 97 9d f4 43 48 97
   Display Name: ATL-FILE-01
   Config File: /vmfs/volumes/52322814-b2c9b3ad-41d8-001018a06dea/ATL-FILE-01/ATL-FILE-01.vmx

To kill the VM:

esxcli vm process kill -t hard -w 5466595

If that doesn't work, use:

esxcli vm process kill -t force -w 5466595



 GEN - Win7x32_PBTPXD_4-baseDisk-datastore-9144/BTP XD_4 GEN - Win7x32_PBTPXD_4-baseDisk-datastore-9144-000028.vmdk

[XD_4] BTP XD_4 GEN - Win7x32_PBTPXD_4-baseDisk-datastore-9144/BTP XD_4 GEN - Win7x3



[XD_4] BTPXD04GEN013/BTPXD04GEN013_IdentityDisk-000002.vmdk

Tuesday, April 26, 2016

DISABLING NETFLOW WITH POWERCLI

Great script for viewing and disabling Vmware Netflow on a VDPortgroup, the below was a couple of quick and dirty scripts to first of all list all VDPortgroups and if they have Netflow enabled, the second was to disable Netflow for a VDPortgroup or a number of VDPortgroups.
This may help with a known issue on ESXi 5.1 when Netflow is enabled:http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=2042370


List all VDPortGroups and if Netflow is enabled

Get-VDPortgroup | Select Name, VirtualSwitch, @{Name="NetflowEnabled";Expression={$_.Extensiondata.Config.defaultPortConfig.ipfixEnabled.Value}}

Function Disable-PGNetflow {
   [CmdletBinding()]
   Param (
      [Parameter(ValueFromPipeline=$true)]
      $DVPG
   )
   Process {
      Foreach ($PG in $DVPG) {
         $spec = New-Object VMware.Vim.DVPortgroupConfigSpec
         $spec.configversion = $PG.Extensiondata.Config.ConfigVersion
         $spec.defaultPortConfig = New-Object VMware.Vim.VMwareDVSPortSetting
         $spec.defaultPortConfig.ipfixEnabled = New-Object VMware.Vim.BoolPolicy
         $spec.defaultPortConfig.ipfixEnabled.inherited = $false
         $spec.defaultPortConfig.ipfixEnabled.value = $false
 
         $PGView = Get-View -Id $PG.Id
         $PGView.ReconfigureDVPortgroup_Task($spec)
      }
   }
}
 
# Disable Netfow for a VDPortgroup
Get-VDPortgroup DPortGroup | Disable-PGNetflow




Monday, April 11, 2016

Changing UCS IP addresses

Changing UCS IP addresses


I have a UCS lab machine that I sometimes take to different locations for proof of concept work.  One of the things I regularly have to do is change the password and hostname.  Here’s how you do it on the command line:
KCTest-A# scope fabric-interconnect a
KCTest-A /fabric-interconnect # set out-of-band ip 10.1.1.23 netmask 255.255.255.0 gw 10.1.1.1
Warning: When committed, this change may disconnect the current CLI session
KCTest-A /fabric-interconnect* # scope fabric-interconnect b
KCTest-A /fabric-interconnect* # set out-of-band ip 10.1.1.24 netmask 255.255.255.0 gw 10.1.1.1
Warning: When committed, this change may disconnect the current CLI session
KCTest-A /fabric-interconnect* # scope system
KCTest-A /system* # set virtual-ip 10.1.1.25
KCTest-A /system* # set name ccielab
KCTest-A /system* # commit-buffer
It’s great because you can change all the IP addresses on each server, the virtual server, and the hostname in one shot.
Source of docs

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...