RSS

Author Archives: Kelvin Wong

vSphere: A colorful DCUI welcome screen

I was tasked to make our ESXi hosts compliant to the security standards and one of them is to set the legal message on DCUI. The work is easy enough, however you end up with only a black screen with the legal text and it looks very ugly!

So I chanced upon two links which shows you how you can add colors and format to the welcome message. Unfortunately, none of them shows you how to get it right.

Read the rest of this entry »
Advertisements
 
Leave a comment

Posted by on March 15, 2019 in powershell, Scripts, vmware

 

Tags: ,

Using REST API calls on VCE Vision

In VCE Vision, you can use REST API calls to grab the status of the overall system, drill down to the individual components and, when required e.g. for support calls, grab the full vblock information into an XML.

Conventionally, you would use a browser using the URL https://vision_core:8443/fm/systems to login and get the overall system’s health in an XML format. To grab the entire XML data you call https://vision_core:8443/fm/{dbid}/allblockdata. Over time, I find that grabbing allblockdata or drilling down to individual components can provide some insight to why a component is showing RED (for example, due connectivity error). Instead of logging in all the time, why not make REST API calls and grab the data instead?

Read the rest of this entry »
 
Leave a comment

Posted by on January 5, 2019 in powershell, Scripts

 

PS: How to get ESXi multipath storage with Powerpath

If your vSphere’s ESXi hosts are connected to storage via EMC’s powerpath, the convention methods of querying path info will not work. Basically, you will get zero results.

For example when you query the lun via MultipathInfo you may only see iSCSI luns listed (if you have them running), but not your datastores. Read the rest of this entry »

 
Leave a comment

Posted by on August 21, 2018 in powershell, vmware

 

PS: Getting a virtual machine’s properties in vRA

Getting the properties of a VM provisioned in vRA is not straight forward, you need to get those information from the IaaS Web server instead of from vRA

This site shows you how you can get to it.

I am not sure which version the author has, but in version 7.2 the properties are not so straight forward and they strangely don’t expand when exported to a JSON file. However let’s first deal with the NTLM authentication on IaaS Web via a Invoke-RestMethod call. Its actually very straight forward, but hard to find; simply speaking, you use get-credential to capture the windows credentials and input it with -credential parameter. Read the rest of this entry »

 
Leave a comment

Posted by on August 2, 2018 in powershell, vmware

 

Tags: ,

PS: Adding nodes to JSON object

Whilst working on vRA REST API to provision new virtual machines, one of task was to get the template for that catalog item and fill in required values.

One of the values common to most templates is the datacenter_location value. By default it will be null. That is not a big deal if you don’t care which datacenter your VM is being provisioned to, but what if you want to specify a location?

...
"_cluster": 1,
"_hasChildren": false,
"cpu": 1,
"datacenter_location":  null,
...

In this case the values should be as such

 "_cluster": 1,
"_hasChildren": false,
"cpu": 1,
"datacenter_location": {
               "classId": "Infrastructure.Compute.DataCenterLocations",
               "id": "DC1"
            },

This is how you can add the values into the JSON object (I am assuming that you already gotten the bearer token in the $vratoken variable) Read the rest of this entry »

 
Leave a comment

Posted by on August 2, 2018 in powershell, vmware

 

Tags: , ,

Daily health check script for VMAX storage

One of the challenge for our cloud team is daily checks. Not coming from a storage background, we did our daily checks by logging on to the storage web gui daily. Interestingly, there is almost no daily check scripts to be found. However, I found a reference in the EMC forum a list of commands to run for a generic health checks.

symcfg list -sid $vmax_sid -env_data -v
symcfg list -sid $vmax_sid -dir ALL
symdev -sid $vmax_sid list -v
symevent -sid $vmax_sid list -error -fatal
symdisk list -sid $vmax_sid -failed

The next task now is to put these into a health check script and figure out the output messages to check for errors.  In general, you just need to check for devices that reports degraded, failed, error or one of standard errors. However for the symdisk command, the execution is different:

symdisk list -sid $vmax_sid -failed

Read the rest of this entry »

 
Leave a comment

Posted by on July 6, 2018 in powershell

 

Tags: , , , , , ,

PS: Continuous ping of a list of VMs

Generally, continuous pings are very easy, we can even do it from Windows command prompt. However, recently, I need a more generic script used to ping a list of VMs and color code status and it expanded from there to include other stuff I want to with the script.

Note that the script is used to ping a set of VMs in my environment that is why the input CSV has VMHost as a column. You can always change this to suit your needs.



Param (
  [Parameter(Mandatory=$true)]
  [ValidateScript({If(Test-Path $_){$true}<span id="mce_SELREST_start" style="overflow:hidden;line-height:0;"></span>else{Throw "Invalid file given: $_"}})]
  [string]$inputfile,
  [int]$count=1,
  [int]$first=0,
  [int]$skip=0,
  [switch]$loop,
  [switch]$v
)

$ListOfVMs = import-csv $inputfile
if ($first -eq 0) {$first = $ListOfVMs.count}
$ListofVMs = $ListofVMs | select -first $first -skip $skip
do {

  Clear
  Write-Host "Checking Status ... "
  Write-Host " "

  foreach ($VM in $ListOfVMs) {
    $VMHost = $VM.VMHost
    $VMName = $VM.Name
    $IPAddress = $VM.IPAddress

    if ($v) {
       Write-Host "Pinging... $VMHost : $VMName with $IPAddress" -ForegroundColor yellow
       Test-Connection $IPAddress -EA SilentlyContinue
    }
    else {
       if (Test-Connection $IPAddress -count $count -quiet -EA SilentlyContinue) {
         Write-Host "$VMHost : $VMName with $IPAddress is UP" -foregroundcolor Green
       }
       else {
         Write-Host "$VMHost : $VMName with $IPAddress is DOWN" -foregroundcolor Red
       }

    }
  }

  Write-Host " "

  $Endloop=$false
  if ([console]::KeyAvailable) {
    $x = [System.Console]::ReadKey()
    if ($x.key -match "Q") {
      $Endloop=$true
	  #[System.Console]::Clear()
	  Write-Host "Keystroke Q detected, quiting loop"
    }
  }

  if ($loop -and !$Endloop) {
    Write-Host "Continuous ping enabled, press Q to end loop ... "
    Write-Host " "
	sleep 1
  }

} while($loop -and !$Endloop)

Write-Host " "

 
Leave a comment

Posted by on April 20, 2018 in powershell

 

Tags: