Powrcli script to get VM name and Guest os name

connect-viserver vcsa-01a.corp.local
$allvm=get-vm

foreach ($vm in $allvm)

{
get-vm $vm|select name,@{name=”Guest os name”‘;e={$vm.exntensionData.Guest.HostName}}
}