Amazing connection, powercli + vsphere cli

Now that was a very very very good post from Robert. You can check this post and his blog at
Once you create this function ‘Add-vCLIfunction’ and run it, you can easly run ‘functions’ from vSphere CLI. This is very very very useful.
All of those perl scripts from vsphere cli will become available for us like a function. Well we can just now simply type ‘vifs’ and bam! One thing worth mentioning here, it does not do the ‘powercli’ ‘powershell’ style output 😉 don’t forget about this, this is not an object. Basically we are still executing perl scripts, so the output is just simple text. But still you receive functions from vSphere CLI.
$a=vicfg-nics -l –server myHost1
$a|get-member -> string[]
Quick example:
I want to download quickly hostd.log from esx box
vifs –server myHost.Local -g /host/hostd.log c:\hostd.log
All sorts of things using vifs:

Check host advanced settings using powercli

I wanted to check settings for NFS that i have in place for all hosts in specific cluster.
Here is what i came up with:

get-cluster 'myCluster' | get-vmhost | %{ $hostn=$_.Name; Get-VMHostAdvancedConfiguration -VMHost $_ | % { $_.getEnumerator()| ? {$_.Key -like "NFS*"}|select Name,Value,@{N='host';E={$hostn}} }  } | export-csv c:\nfssettings.csv
----Output before sending to export-csv
Name                            Value host
----                            ----- ----
NFS.WorldletAffinity            x     host1
NFS.VolumeRemountFrequency      y     host1
NFS.LockUpdateTimeout           z     host1
NFS.LogNfsStat3                 y     host2

In nfssettings.csv you will have nice table with nfs_setting_name , value, and host name from which it was taken.
What’s with the $_.GetEnumerator() ?, right, so when you will run

Get-VMHostAdvancedConfiguration -vmhost "your_host" | gm

You will notice that we are receiving hashtable. Since this is hashtable we can not fitler it with just simple where,select as this comes as a 1 BIG table. It looks like it consists of rows etc etc… so you would think that those are several objects, but at the end it is just like 1 big hashtable 😉 So we want to have ability to go through each element in this hashtable to search only for those with key similar to NFS*. Obviously if you want to search for other things like NFS, then put the proper name instead of NFS.

Get-VMHostAdvancedConfiguration -vmhost "your_host"
(Get-VMHostAdvancedConfiguration -vmhost "your_host").GetEnumerator()

Although they output is the same, when you are using GetEnumerator it is possible for you to do select with where-object.
Instead of receiving object type of hashtable, we are receiving now multiple System.Collections.DictionaryEntry which have Key and Value property. That’s why now we can use Where-Object to seek for your NFS settings.Since we are querying all host systems within cluster i want to have also a column with host name so that’s why i had to do $hostn=$_.Name; in the loop. To store the host name because this information would be lost in next pipeline.