VMware Communities
HarjitSB
Enthusiast
Enthusiast

PowerCLI - Manual Input && Combine Output

Hello Team,

I am preparing a PowerCLI Script when I can given manual Input and combine the output of two commands. The requirement is:

For selected VMs

- Powered ON / OFF .

- UUID of these VM's .

- Esx Host Names of which these VM's belong to .

- UUID Of ESX Host .

I have prepared as-->

# Prompt for VC

$vCenter = Read-Host "Enter vCenter Name or IP"

Connect-VIServer $vCenter

$CSVFilepath = "C:\Test.csv"

$VM = Read-Host "Enter VM Name"

Get-VM $VM |select name, PowerState, @{n="VMUUID";e={(Get-View $_.Id).config.uuid}} | out-file -FilePath $CSVFilepath -append

Get-VM $VM |Get-VMHost | Select Name,@{n="HostUUID";e={$_.ExtensionData.hardware.systeminfo.uuid}} | out-file -FilePath $CSVFilepath -append

Q1 - Script should ask to enter the VM name again and again.

Q2 - Combine the output in single CSV file with different data in separate columns.

Pls help, as I m not able to create foreach and combine the output.

Rgds

-Harjit

0 Kudos
0 Replies