?
Solved

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

Posted on 2013-06-18
5
Medium Priority
?
1,534 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 2000 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

This script can help you clean up your user profile database by comparing profiles to Active Directory users in a particular OU, and removing the profiles that don't match.
A brief introduction to what I consider to be the best editor for PowerShell.
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

801 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