Solved

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

Posted on 2013-06-18
5
1,401 Views
Last Modified: 2013-06-18
I have the following code
Get-VM | Get-View | ForEach-Object { $_.Guest.Net } | select Network

Open in new window

and outputs the following:
Network
-------
VM Network 126
VM Network - DMZ
VM Network - DMZ
VM Network - LAN
VM Network 126
VLAN63
But when i have the following code:
$array3 = Get-VM | Get-View | ForEach-Object { $_.Guest.Net } | select Network

Open in new window

and type
write-host $array3[0]

Open in new window

i get the following output:
@{Network=VM Network 126}
and when populating the excel file with the following
$Sheet.Cells.Item($intRow,$intColumn) = $array3[$i]

Open in new window

it breaks,  the right entry should be VM Network 126 and so on...
0
Comment
Question by:namerg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 500 total points
ID: 39257965
Try..
$Sheet.Cells.Item($intRow,$intColumn) = $array3[$i].Network

Open in new window

BTB, why not directly export data to csv using
Get-VM | Get-View | ForEach-Object { $_.Guest.Net } | select Network | Export-csv test.csv

Open in new window

0
 

Author Comment

by:namerg
ID: 39257968
I was doing the CSV, but I realized the formatting and locating cells(rows,columns) in the CSV, was going to be kind of difficult :(
Let me try the code
0
 

Author Comment

by:namerg
ID: 39258016
You got it...do you know why it gets locked out by the powershell session if i want to delete the xlsx ?
0
 
LVL 40

Expert Comment

by:Subsun
ID: 39258041
You probably didn't close the file in script..
0
 

Author Comment

by:namerg
ID: 39258111
Nahhh, i am closing it...ohh well i posted a question thought.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A brief introduction to what I consider to be the best editor for PowerShell.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question