Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1759
  • Last Modified:

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

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
namerg
Asked:
namerg
  • 3
  • 2
1 Solution
 
SubsunCommented:
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
 
namergSystems AdministratorAuthor Commented:
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
 
namergSystems AdministratorAuthor Commented:
You got it...do you know why it gets locked out by the powershell session if i want to delete the xlsx ?
0
 
SubsunCommented:
You probably didn't close the file in script..
0
 
namergSystems AdministratorAuthor Commented:
Nahhh, i am closing it...ohh well i posted a question thought.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

NEW Internet Security Report Now Available!

WatchGuard’s Threat Lab is a group of dedicated threat researchers committed to helping you stay ahead of the bad guys by providing in-depth analysis of the top security threats to your network.  Check out this quarters report on the threats that shook the industry in Q4 2017.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now