VMware Cloud Community
BarryCoombs
Contributor
Contributor
Jump to solution

Convert to HTML

Hi Guys,

Hopefully another quickone I have the following script

get-vm | Where { $_ | Get-CDDrive | Where { $_.ConnectionState.Connected -eq "true" } } | select @{ Name="Guests"; Expression={$_.name}} | select Guests

When I run this in the PowerCLI I get the following

Guests

-


CW-DemoVC

Demo-Web

Now if I modify the script to look like this

get-vm | Where { $_ | Get-CDDrive | Where { $_.ConnectionState.Connected -eq "true" } } | select @{ Name="Guests"; Expression={$_.name}} | select Guests | convertto-html -head $head -body $header -title $title | out-file -Append c:\test.html

I get this

*

CW-DemoVC

Demo-Web

Why do I get the * in my HTML file and how do I change it to something more meaning full

Cheers

www.virtualisedreality.com | www.twitter.com/virtualisedreal

www.virtualisedreality.com | www.twitter.com/virtualisedreal
Reply
0 Kudos
1 Solution

Accepted Solutions
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Sorry to but in, I know you are probably looking into this Luc but I have had this before, its because the convertto-html cmdlet doesnt know the name of objects with a single property, if you changed it to this it would work fine... get-vm | Where { $_ | Get-CDDrive | Where { $_.ConnectionState.Connected -eq "true" } } | select Name, Host | convertto-html -head $head -body $header -title $title | out-file -Append c:\test.html

I recently discussed this on the get-scripting podcast as a "feature" !

If you found this information useful, please consider awarding points for Correct or Helpful.

Alan Renouf

http://virtu-al.net

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com

View solution in original post

Reply
0 Kudos
5 Replies
LucD
Leadership
Leadership
Jump to solution

What's in the $head, $header and $title variables ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

BarryCoombs
Contributor
Contributor
Jump to solution

These are completed earlier in the script, this is part of a larger post project completition script im attempting to write :smileylaugh:

www.virtualisedreality.com | www.twitter.com/virtualisedreal

www.virtualisedreality.com | www.twitter.com/virtualisedreal
Reply
0 Kudos
alanrenouf
VMware Employee
VMware Employee
Jump to solution

Sorry to but in, I know you are probably looking into this Luc but I have had this before, its because the convertto-html cmdlet doesnt know the name of objects with a single property, if you changed it to this it would work fine... get-vm | Where { $_ | Get-CDDrive | Where { $_.ConnectionState.Connected -eq "true" } } | select Name, Host | convertto-html -head $head -body $header -title $title | out-file -Append c:\test.html

I recently discussed this on the get-scripting podcast as a "feature" !

If you found this information useful, please consider awarding points for Correct or Helpful.

Alan Renouf

http://virtu-al.net

Blog: http://virtu-al.net Twitter: http://twitter.com/alanrenouf Co-author of the PowerCLI Book: http://powerclibook.com
Reply
0 Kudos
BarryCoombs
Contributor
Contributor
Jump to solution

Cheers guys looks likes like I owe you two a beer!

www.virtualisedreality.com | www.twitter.com/virtualisedreal

www.virtualisedreality.com | www.twitter.com/virtualisedreal
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

No problem Alan, I was in a meeting (yes we do have those as well).

Thanks for the informing us of that "feature".


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos