Quantcast
Channel: VMware Communities : Discussion List - vRealize Orchestrator
Viewing all articles
Browse latest Browse all 6251

Ever need the VM Serial Number?

$
0
0

I found myself in need of getting the serial number of a virtual machine and did not want to have to get inside the VM to get it so I have a little script that gets me this information from the vm object that I wanted to share in case this can help anyone else out.  in the script serial_number is the output and vm is the VC:VirtualMachine object

 

var serial_number = "VMware-"

var biosID = (vm.config.uuid.split('-').join(""))

var str = biosID

    a = [];

for (var i = 0; i < str.length; i += 2) {

    a.push(str.substr(i, 2));

  if (str.length = 30) { str += "-" } else { str += " " }

}

//System.log(a); // prints the array

//System.log(a.join(" ")); // turn the array into a string of hex values

//System.log(parseInt(a[1], 16)); // parse a particular hex number to a decimal value

var uid = (a.join(" "));

var trim = uid.split("-").join("")

serial_number += trim

 

 

Cheers!!


Viewing all articles
Browse latest Browse all 6251

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>