0

My first variables, is someting like: name OS version ---- ---- kead windows 2019 hanacockpit SLES12SP3 My second variables, is like

name GB ---- ---- kead 54.081582998856902122497558594 hanacockpit 384.20552698988467454910278320

As you can see the first column is name, as long as the second one has the same name,let's say kead,Join GB accordingly.

The final output is name OS version GB ---- ---- --- kead windows 2019 54.081582998856902122497558594 hanacockpit SLES12SP3 384.20552698988467454910278320

Anyway to do it?

Actually, variable1 and variable2 are from ESXI powercli.

# skip connection.

$all=Get-VM | 
   Get-View -Property @("Name", "config.GuestFullName") | 
   Select -Property Name,
       @{N="OS";E={$_.Config.GuestFullName}}

$space =get-vm | Select Name,@{N="disk-size";E= {@([math]::Round($_.ProvisionedSpaceGB / 1))}}


newbie
  • 11
  • 3

1 Answers1

0

Maybe it's not quite what you're asking for, but you could just re-write your command into a one-liner...

Example:

   Get-VM | Select Name, @{N="OS";E={$_.ExtensionData.Config.GuestFullName}}, @{N="disk-size";E= {@([math]::Round($_.ProvisionedSpaceGB / 1))}}

If you're just looking for the join, my preference has generally been Join-Object: https://devblogs.microsoft.com/powershell/join-object/

Kyle Ruddy
  • 1,886
  • 1
  • 7
  • 5