Get Cloud Director VM Inventory with Storage Info (KB#00097)

 Hello Guys,

Keep fighting with Corona and keep your spirit up. It will help 😊

I got this challenge in form of a request from my customer. He requested all VM's info including cpu, mem and disk size. Initially I thought what's a big deal in it but then when I actually started writing code, I had the feeling like "What the heck" LOL!

Guys who already dealt with it, might know my pain. I started browsing google and found that many people are asking same question and I found vmware community thread too was unanswered. After a extensive search and hard work, I could do it. Below is the code guys:


==========
Function Get-CIVMInventory {
$ppp = Read-host "enter the vm name"
$vms = Get-CIVM -Name $ppp
Foreach ($vm in $vms){
$ee = $vm.ExtensionData.GetVirtualHardwareSection().item | Where {$_.Description -like “Hard Disk”}
$ff = $ee.VirtualQuantity.value
foreach ($f in $ff){
Get-CIVM -Name $vm | Select @{N="Name";E={@($vm.Name)}}, CPUCount, MemoryGB, @{N="DiskSize(GB)";E={@($f/1024/1024/1024)}}
}
}
Get-CIVMInventory
}
=========

Above is for single VM, you might be having requests like you want to fetch for all VMs in your cloud director environment then please use below code:

========
$vms = Get-CIVM
$output = Foreach ($vm in $vms){
$ee = $vm.ExtensionData.GetVirtualHardwareSection().item | Where {$_.Description -like “Hard Disk”}
$ff = $ee.VirtualQuantity.value
foreach ($f in $ff){
Get-CIVM -Name $vm | Select @{N="Name";E={@($vm.Name)}}, CPUCount, MemoryGB, @{N="DiskSize(GB)";E={@($f/1024/1024/1024)}}
}
}
$output | Import-Csv C:\Temp\fra_vcd_vm_invent.csv
=========

It is tested and working for me. Give it a try and let me know if it doesn't work for you😊 I answered the VMware thread too.

Create/Update Metadata of Cloud Director Objects (KB#00096)

Overview

You can easily create/modify metadata for any Cloud Director object using GUI but it is a challenge if there is no option to modify or create metadata from GUI and according to your requirement. This is the issue with VMware Cloud Director 10.1.2. This version not only doesn't have this option from GUI but also existing metadata entries are not editable from GUI. This is the reason, I had to find some other way out.

As a solution, either you need to do it from APIs or from PowerShell. I will demonstrate both ways here. You may choose which sounds easy for you. Same method will be followed in future versions as well if VMware haven't plan to change the Metadata Format as they did for older versions of vCD. This is the reason that most of the articles on web don't give you exact information as those are outdated now.

Solution 1: From PowerCLI

=======
$vcd = Read-Host "Enter fqdn/IP here"
Connect-CIServer $vcd
#In below line, you need to specifiy the object whether it is VM, vAPP, Org or OrgvDC. Command will change accordingly. For example, for VM, you will use Get-CIVM. For Org, you will use Get-Org and so on...
$vapp = Get-CIVApp -Name testconsole
$metadata = $vapp.extensiondata.GetMetadata()
$metadata.MetadataEntry = New-Object VMware.VimAutomation.Cloud.Views.MetadataEntry
$metadata.MetadataEntry[0].Key = "vCnotes"
$metadata.MetadataEntry[0].TypedValue = New-Object VMware.VimAutomation.Cloud.Views.MetadataStringValue
$metadata.MetadataEntry[0].TypedValue.Value = "test"
$metadata.MetadataEntry[0].Domain = New-Object VMware.VimAutomation.Cloud.Views.MetadataDomainTag
$metadata.MetadataEntry[0].Domain.Visibility = "readonly"
$metadata.MetadataEntry[0].Domain.Value = "SYSTEM" $vapp.ExtensionData.CreateMetadata($metadata)
=======

Copy the above lines and change it according to your environment and run it. You need to modify the yellow highlighted value according to your environment.

Note that : 

1. To update existing entry, you can run above command by keeping key name same. It will update the existing keys.
2. If you are Tenant Administrator then you won't be able to see the private visible keys but still can modify using this commands.

Solution 2: From any API Tool : It is lengthy and complex one.

I will take sometime to update this post. Meanwhile, enjoy using Solution 1 ;)

For any doubt/error in powercli, feel free to comment.

Reset root account password without restarting esxi host (KB#00095)

Overiew

Generally, if you forgot root account password then you reboot the appliance and then enter grub menu by pressing key 'e' during the boot and then you put the keywords rw init=/bin/bash in the last of first line then you press F10 to save and continue for temp login with root account.

But what if you can't reboot esxi host and have to reset the root password as well. In other words, what if you want to reset root account password without rebooting it anytime.

Sounds interesting, isn't it?

Solution

I will update this post by next weekend. Stay tuned guys!!



Thank you

Check Free IP addresses in Network Pool in Cloud Director (KB#00094)

Overview

This is actually not a big deal when you can check this in cloud director GUI and you would see number of articles to explain this from GUI. But, if there is no option to check the IP address allocation from GUI then it would be far difficult for you if you only work with GUI. My customer reported me that he can't see the assigned or allocated IP addresses and had to ping each and every IP address to check whether its allocated or not. It is actually a headache.

Issue

Two issues were there

1. Checking IP allocation for external network is restricted to System Administrator. My customer was tenant administrator and wanted to check this which is not possible due to product design.
2. If you are System Administrator, you might not get any option to extract the list of IP addresses to store with you or use in excel for quick filter and highlight of free IP addresses etc..
3. Checked on VMware Cloud Director versin 10.1.2

Solution 

Credit goes to powershell here. I could create below script which easily could give you the results. Just copy below output and then paste it into powershell screen from where you can access your cloud director environment.

#

$vcd = Read-Host "Enter vCD url to connect"

Connect-CIServer $vcd

$network = Read-Host "Enter the name of network here"

$ExtNet = Get-ExternalNetwork -Name $network

$ExtNet.ExtensionData.Configuration.IpScopes.IpScope.allocatedipaddresses.IpAddress | Out-GridView

#

Below is sample out-


let's verify the sample output from GUI-


Let me know if you have any thought around it. 

Thank you.

 

Check and Modify Security Protocols in VMware Appliances(KB#00093)

Overview

It is just to centralize the configuration method of security protocols like TLS or SSL in all VMware appliances. VMware did a good job in documenting this process and I am just putting all in one view.  I will add the product in the list if I feel that it needs to be here.

For vCenter Server -

To check :

1. Connect with vCenter server appliance with SSH with its management IP address
2. Run below command#

#cd /usr/lib/vmware-vSphereTlsReconfigurator/VcTlsReconfigurator/
#./reconfigureVC scan

Below is the sample output : TLS Version is TLSv1.2. It means that TLSv1.2 is enabled and any other version is disabled. 


To update in vCenter version 6.5 and 6.7:

Managing TLS protocol configuration for vSphere 6.5/6.7 (2147469) (vmware.com)

To update in vCenter version 7.x

Enable or Disable TLS Versions on vCenter Server Systems (vmware.com)


For vCD or VMware Cloud Director

To check :

1. Login vCD or cloud director appliance
2. Run below command#

#cd /opt/vmware/vcloud-director/bin
#./cell-management-tool ssl -protocols -l

Below is the sample output :


To update:

Note : It need downtime and need to update on each cell individually. So please shutdown the vCD services first before doing this. Follow this article for this vCD | Upgrade from version 9.5 to 10.1.2 ~ My vCloud Notes (vcnotes.in)

#./cell-management-tool ssl-protocols -d SSLv3,SSLv2Hello

Follow this VMware article to update 


For vRealize Automation 

To check and update, just follow this article

For vRealize Log Insight

Good article by vendor.

For NSX for vSphere (NSX-V)

Please see this documentation.

For ESXI Host

Worth to check this page here.

For vROPS

Please click here to check this.