VMware Cloud Community
tianhailong666
Enthusiast
Enthusiast

Can not accumulated data via Excel sheet

Dears,

I have wrote a script about collect a accumulated data  via Excel sheet, But  I run  this  script and there is no response.      Does syntax is wrong for while loop?      I  apprecaiated your kindly reply ,thanks very.

Param([string]$file)

$excel = New-Object -ComObject Excel.Application

$excel.Visible = $False

$workbook = $excel.Workbooks.Open($file)

$sheet = $workbook.Worksheets.Item("PC服务器虚拟机")

$i = 4

$project = $sheet.Cells.Item($i,1).text

$Name = $sheet.Cells.Item($i,3).text

$Temp = $sheet.Cells.Item($i,5).text

$NumCpu = $sheet.Cells.Item($i,6).text

$NumMem = $sheet.Cells.Item($i,7).text

$SizeDisk = $sheet.Cells.Item($i,8).text

$Clustername = $sheet.Cells.Item($i,13).text

$ESXi = $sheet.Cells.Item($i,14).text

$Vlan = $sheet.Cells.Item($i,17).text

$value = @{"Itemname" = "$project" ;

"vmname" = "$Name" ;

"Tempname" = "$Temp";

"NumCpu" = "$NumCpu";

"NumMem" = "$NumMem";

"SizeDisk" ="$SizeDisk";

"Clustername" = "$Clustername";

"ESXi" = "$ESXi" ;

"Vlan" = "$Vlan" }

$vms = @()

while ( $value.vmname -ne "" )

 

{

  $vms += $value

  $i++

  }

 

$excel.Workbooks.Close()

$excel.Quit()

Reply
0 Kudos
1 Reply
Prakas
Enthusiast
Enthusiast

It looks like you haven't saved the excel.

Reply
0 Kudos