VMware Cloud Community
gerf0727
Enthusiast
Enthusiast

How to export network name into an excel cell ?

Hello,

I have the following code:

$array3 = Get-VM | Get-View | ForEach-Object { $_.Guest.Net } | select Network

but it breaks here:

$Sheet.Cells.Item($intRow,$intColumn) = $array3[$i]

Exception setting "Item": "Exception from HRESULT: 0x800A03EC"

At C:\scripts\VMware\HealthCheck_vCenter2_xls.ps1:498 char:19

+     $Sheet.Cells.Item <<<< ($intRow,$intColumn) = $array3[$i]

    + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException

    + FullyQualifiedErrorId : CatchFromBaseAdapterParameterizedPropertySetValueTI

Thanks for your help.

Tags (2)
Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership

I would need to see a bit more of your script to be sure, but the problem looks like the one in PowerShell to Excel Cell error


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
gerf0727
Enthusiast
Enthusiast

LucD, thanks for the message. I think I figured it out. I did replace $Sheet.Cells.Item($intRow,$intColumn) = $array3[$i] with the following line $Sheet.Cells.Item($intRow,$intColumn) = $array3[$i].Network

I get the Network Names as expected in the respective cells


Network Name
VM Network 126
VM Network - DMZ
VM Network - DMZ
VM Network - LAN
VM Network 126
Reply
0 Kudos