Solved

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

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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This script checks a path to see if a folder exists. If the folder does exist you will get output "The folder has previously been created. No action taken" If not it will create the folder. Then adds one user modify permission to the folder. It …
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 video discusses moving either the default database or any database to a new volume.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now