ConvertTo-HTML; outputting information from Numerous Servers

I have been messing with this for a little while, I am stuck on getting the right output.
here is the output that I am getting.

ComputerName LastBoot LastUpdate
localhost 7 8
ComputerName LastBoot LastUpdate
ComputerName LastBoot LastUpdate
ComputerName LastBoot LastUpdate

here is the output I am wanting. (single table - 1 row of headers)
ComputerName LastBoot LastUpdate
localhost 7 8

I thought that it would be best to do it with fragments, and this is where I am stuck.

(I have attached the script (it includes the two functions I am calling)

Any help would be greatly appreciated.

(*note to Don, the goal it to get to ConvertTo-EnhancedHTML, but I thought it best to get it working with ConvertTo-HTML first. :slight_smile: )

Here’s the file with a .txt extension

Every time you create an HTML page or an HTML fragment, you get a complete table including column headers. There’s no way to not get that - it’s what ConvertTo-HTML does.

You’re doing the right thing in terms of having functions that output objects, but it’s what you’re doing with those objects that isn’t helping. For example, your functions accept computer names from the pipeline, but you’re not using that feature.

Get-Content c:\temp\computers1.txt | Get-UpdateInfo | ConvertTo-HTML | Out-File drives.html

Should do what you want. What you’re doing now is creating an HTML fragment FOR EACH computer. You don’t actually need that ForEach loop you’ve created. You did the right thing, but then overcomplicated it ;).


Thanks for the help, I have been going through your CBT on PowerShell 3 Tool making. This was the script that I decided to improve. I have to say after going through that CBT, my scripting process has improved immensely. Your deep dive at TechEd, and the comments you made in the beginning, on selling your scripting ability, resonated a lot. So thank you, btw.

I tend to overcomplicate things, when they seem to easy :slight_smile:



Tried the command you gave me, and it has uncovered a different error.
Now it says my function Get-Updateinfo doesn’t take pipeline

“Get-Updateinfo : The input object cannot be bound to any parameters for the
command either because the command does not take pipeline input or the input
and its properties do not match any of the parameters that take pipeline input”

does my text file need to be started with the field computername? (the mandatory variable is computername)
any suggestions or direction to look at would be appreciated. I will keep this thread posted of any movement.


Yuo’re hacking this together from someplace else aren’t ya? :slight_smile:


Should be


You have it correct in the first function, but not the second one.

However, as written, you’ll notice it only takes one computer name, and the function isn’t properly written to deal with multiple computer names. You’re going to have to deal with that. Your first function is a model of a well-written function; the second one isn’t as flexible. Given the disparity between the two, I’m not sure what direction you want to go.

No I am not hacking this together… :stuck_out_tongue: (If was hacking it together it probably would be much more functional!)
The first function is what I did while following your course…the second one is me trying to do a coordination script to pull just the information I need at the time.
and to display it nicely.

I will look at my second function and see what I can figure out.
You have been a great help, I now know where to look and what to look at, that is a large part of the battle!

thank you!

It might actually be easier to not use the second function, in that case. You could pipe Get-Content right to your first function easily enough. The output from that could probably be sent through Where-Object to filter out what you want, and then Select-Object to construct the output you want. Since those are already geared for the pipeline, it might be easier.

and that my friend is why you are the master.
I have it working with the where-object and the select-object and the convertto-html.
Now some fine tuning of my original function I will be set.
thank you, I really do appreciate the guidance.
After this one, I have to write a decent function for sending these reports as an email… :slight_smile:

Send-MailMessage -BodyAsHTML :slight_smile:

Now your just showing off!!! :stuck_out_tongue: (thank you)