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
Solved

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

Posted on 2013-06-18
5
1,376 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
  • 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

I thought I'd write this up for anyone who has a request to create an anonymous whistle-blower-type submission form created using SharePoint 2010 (this would probably work the same for 2013). It's not 100% fool-proof but it's as close as you can get…
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.
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

790 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