Get UUID of a VM (VM-ID) from InGuest (inside a VM)

Aus Wiki-WebPerfect
Wechseln zu: Navigation, Suche
$uuid = (Get-CimInstance -ClassName Win32_BIOS).SerialNumber 
$regexpattern = 'VMware-((?:(?:[a-zA-Z-0-9]{2})\s){4})((?:(?:[a-zA-Z-0-9]{2})\s){2})((?:[a-zA-Z-0-9]{2})\s(?:[a-zA-Z-0-9]{2}))-((?:(?:[a-zA-Z-0-9]{2})\s){2})((?:(?:[a-zA-Z-0-9]{2})\s){5}(?:[a-zA-Z-0-9]{2}))'
 
($uuid -replace $regexpattern, '$1-$2-$3-$4-$5') -replace " "


Use this as a Zabbix "system.run" item

Because of a Zabbix character limit in the item field, I had to rewrite the regex pattern. Zabbix Item Key

system.run["powershell.exe ((gwmi Win32_BIOS).SerialNumber -ireplace '.+((([\w0-9]{2})\s){4})((([\w0-9]{2})\s){2})(([\w0-9]{2})\s([\w0-9]{2}))-((([\w0-9]{2})\s){2})((([\w0-9]{2})\s){5}([\w0-9]{2}))','$1-$4-$7-$10-$13') -replace ' '"]