Very nice PowerCLI session from VMworld 2013 !

VSVC4944 – PowerCLI Best Practices – A Deep Dive
Luc Dekens , Eurocontrol
Alan Renouf , VMware


How to check which virtual machines have vmware tools time sync enabled

If we would like to quickly see which virtual machines have the option to sync time using vmware tools enabled we can use this one liner:

get-view -viewtype virtualmachine -Filter @{'Config.Tools.SyncTimeWithHost'='True'} | select name

After this you will receive a list with VM name that have their vm tools time sync enabled.
One more thing that is worth reading while thinking about virtual machine tools time synchronization is this:
Disabling Time Synchronization (1189)

And some more information about troubleshooting esx/esxi host system regarding ntp.
Troubleshooting NTP on ESX and ESXi (1005092)
If you would like to change policy for vm tools time sync you can see how i was changing the vmware tools upgrade policy and just change 1 line in the code:
from:$ = “upgradeAtPowerCycle”
to:$ = $true // or $false
And this will do the trick.

How to check time on ESXi via esxcli, changing ntp servers, restarting ntpd service

If we would like to check what time do our hosts have we can write a simple one liner:

foreach($esxcli in get-vmhost|get-esxcli){""|select @{n='Time';e={$esxcli.system.time.get()}},@{n='hostname';e={$esxcli.system.hostname.get().hostname}} }

Output should be similar to:

So what we are actually doing is:
1) get access to all hosts esxcli
2) on each of those esxcli to run command: esxcli system time get and esxcli system hostname get
3) output with columns time and hostname
This will output time from all our esxi host systems that are registered in the virtual center to which we are connected in current powercli session.
If you do not want to it for all hosts simply manipulate the get-vmhost , like get-vmhost -Location ‘xxxx’

I also had to change ntp servers for my hosts so:

foreach($vmhost in get-vmhost){
#stop ntpd service
$vmhost|Get-VMHostService |?{$_.key -eq 'ntpd'}|Stop-VMHostService -Confirm:$false
#remove ntpservers 
$vmhost|Remove-VMHostNtpServer -NtpServer $oldntpservers -Confirm:$false
#add new ntpservers
$vmhost|Add-VmHostNtpServer -NtpServer $newntpservers
#start ntpd service
$vmhost|Get-VMHostService |?{$_.key -eq 'ntpd'}|Start-VMHostService

Querying ITSM Incident tickets from Powershell

I have spent few days now in order to get information about tickets that are stored in ITSM. In order to query for INCident ticket in BMC ITSM we need
the uri to the webservice. How to get it ?
Access your internal ITSM server to get list of webservices:

You will be prompted for user and password. Authenticate. After this you will receive a list of Web service name, service type, description. Copy link to
HPD_IncidentInterface_WS . This one will allow us to query our incident tickets.
Should be something like this:
In order to consume it i use this uri:
Replace the ‘protected’ with ‘public’

Open powershell console and do the following:
$myitsm=New-WebServiceProxy -Uri $uri -Namespace ITSM
Let’s complete authentication:

$auth= New-Object ITSM.AuthenticationInfo
$auth.password= [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($cred.password))

You can always put it in plain text ($auth.username=’myuser’ // $auth.password=’yourpassword’)
Let’s set a INC number that we will be looking for

Let’s build the search criteria

$criteria=”‘Incident Number’ = “”$tid”””

If you would like to build criteria based on your name and surname then it would look like this:
$criteria=”‘First Name’ = “”Grzegorz”” AND ‘Last Name’ = “”Kulikowski”” ”

Ok, lets perform our search. In my case i know that i will only receive 1 INC ticket.
$answer.count -> that will be 1 now as i have only 1 INC in my queue
the method: HelpDesk_QueryList_Service asks for ( search criteria, starting record number, maximum records returned)
i can now open my INC ticket to see what is inside, sample output:

Assigned_Group                 : Greg Team
Assigned_Support_Organization  : Greg Team Org
Assignee                       : Grzegorz Kulikowski
City                           : Monki
Closure_Product_Category_Tier1 : Application
Company                        : Greg S.A
Country                        : Polska
Department                     : IT section
Summary                        : test123
Notes                          : test123
First_Name                     : Grzegorz
Impact                         : {Item4MinorLocalized}
Incident_Number                : INC000000049839
Internet_Email                 :
Last_Name                      : Kulikowski
Product_Categorization_Tier_1  : Application
Product_Categorization_Tier_2  : Infrastructure Services
Reported_Source                : {DirectInput}
Service_Type                   : {UserServiceRestoration}
Status                         : {InProgress}
Urgency                        : {Item4Low}
HPD_CI                         : Server

I have listed only few from the properties.

So actually, to run your query this portion of code is enough:

$myitsm=New-WebServiceProxy -Uri http://itsm.midtier.lan/arsys/WSDL/public/itsm.midtier.lan/HPD_IncidentInterface_WS -Namespace ITSM
$auth= New-Object ITSM.AuthenticationInfo
$auth.password= [System.Runtime.InteropServices.marshal]::PtrToStringAuto([System.Runtime.InteropServices.marshal]::SecureStringToBSTR($cred.password))
$criteria="'Incident Number' = ""$tid"""

It does not look scary 😉 Took me some time to figure this out though. In next post i will try to show how to query for Changes and how to update tickets,crqs. Have in mind that i am not ITSM specialist, just end-user of this application. If you have any documents about using itsm web services, please share it in comments.

Useful links:
BMC Remedy IT Service Management 7.0 Integration
Using BMC ITSM OOB Web Service

In case of having issues check this post as well:

Failed to launch the MKS client: The system cannot find the file specified

Evening troubleshooting…
I was sitting on #vmware irc channel today and i was interested in problem that one person had. He had fresh installation of esxi 5.1 on a brand new box, few vms, but for some reason he could not connect to vm remote console using vsphere client. We went through a lot of checking, many KBs and so on and on, cables, cards, nics, fw, dns… still nothing.
What we did at the end is that we were watching with ‘ tail -f /var/log/hostd.log ‘ the log, while he tried to open the console. And we finally saw :

2013-08-06T20:55:00.177Z [47696B90 verbose ‘Default’] Timed out reading between HTTP requests. : Read timeout after approximately 50000ms. Closing stream TCP(local=, peer=
2013-08-06T20:55:00.177Z [470E2B90 error ‘Solo.HttpSvc.HTTPService’] Failed to read request; stream: TCP(), error: N7Vmacore16TimeoutExceptionE(Operation timed out)
2013-08-06T20:55:02.061Z [47738B90 verbose ‘SoapAdapter’] Responded to service state request

So there had to be something with the connection/port.

vSphere client log was showing:

2013-08-06T15:07:51.557-05:00| vmrc| I120: VMClient_ConnectMksClientEx – connecting the MKS client
2013-08-06T15:07:51.557-05:00| vmrc| I120: VMClientConnectMKSClientEx
2013-08-06T15:07:51.558-05:00| vmrc| I120: cui::MKS::OnSetAttachedError
2013-08-06T15:07:51.558-05:00| vmrc| I120: cui::vmrc::DlgMgrImpl: “Unable to connect to the MKS: Failed to launch the MKS client: The system cannot find the file specified

vmware.log from vm had a lot of those entires:

2013-08-06T02:47:41.373Z| mks| I120: SSL Error: error:140780E5:SSL routines:SSL23_READ:ssl handshake failure
2013-08-06T02:47:41.373Z| mks| I120: SOCKET 6 (140) recv error 0: Success
2013-08-06T02:47:41.373Z| mks| W110: SOCKET 6 (140) Error during authd-VNC negotiation: (1) Asyncsocket error.

Firewall in windows was said to be disabled.

Solution: i asked if it possible to try to connect with vSphere client from another workstation which is not in Active Directory, as that computer from which that person was connecting to that esxi host was in active directory.
B.I.N.G.O 😉

That system was in AD where there were very strict policies, which were causing problems with making connections on 903 tcp port which is utilized when accessing the vm remote console. As soon as he made the connection from workstation that was not part of that AD/policy, VM console was opened without any issues.

23:33 -Krazypoloc- Holy shit the non domain machine works fine!
23:34 -Krazypoloc- Thanks for all your help man
23:35 -Krazypoloc- nostrovia
23:35 -Krazypoloc- 🙂
23:35 -gregu– no problem

🙂 I’m pretty sure that he was trying to say:
Na zdrowie !
here it is 😉

Invalid virtual machine configuration error while deleting snapshot.

When you you will receive an error :
“Invalid virtual machine configuration.”


While deleting or creating virtual machine snapshot you might have an issue with the snapshot dictionary file *.vmsd. To ensure that this is the case open the virtual machine log file (vmware.log), and browse through it. If you will see entries like:

DictionaryParseReadLine: syntax error with line, “.”.
SNAPSHOT: SnapshotConfigInfoReadEx: Unable to load dict from ‘/vmfs/volumes/xxx/VMfolder/VMname.vmsd’.
SNAPSHOT: SnapshotConfigInfoReadEx failed for file ‘VM.vmx’: Dictionary problem (6)

Then it might be the case where your vmsd file is not correct.
I found KB for this case . Basically you need to rename your vm.vmsd file to vm.vmsd.old file, and after that recreate it by creating new snapshot. Once this is done, go through vSphere client to the snapshot manager and use the ‘delete all’ button in order to get rid of all snapshots.

You also might want to double check your snapshot chain by reading the vmdk descriptors, and looking if parentCID/CID matches through the entire snapshot chain.

Don’t worry about the fact that in snapshot manager you can only see the snapshot you have just created. When you will click ‘delete all’ he will delete all snapshots in the chain. After this is completed, ensure that it was done by checking from which disk virtual machine is working and by reading vmsd file. Check if the directory does not contain any -00000 delta files.