Find out on which Hyper-V host the node is running

Hyper-V

Sometimes if you using Hyper-V, you like to find out on which Hyper-V host the node is running. Here are two solutions for Linux to find the right host.

ruby

IO.binread('/var/lib/hyperv/.kvp_pool_3')[/\HostName(.*?)HostingSystemEditionId/, 1].scan(/[[:print:]]/).join

bash

strings /var/lib/hyperv/.kvp_pool_3|sed -n '/PhysicalHostNameFullyQualified/ {n;p}'