I’ve been working on Powershell to extract data and I need to export the data I’ve gotten to an html file. It sounds simple because of the cmdlets, however its outputting the wrong thing.
My code is:
c:> get-servergroup | %{$_. Name + " " + $_.ServerOff + " " + $_.ServerOn}
This then produces a small table below with the names and which servers are on and off. However when I add on the converting cmdlet like below:
c:> get-servergroup | %{$_. Name + " " + $_.ServerOff + " " + $_.ServerOn} | Convertto-html | Out-file Test.html
it gives me 3 values like * 35 62 So really, I just want to know if there’s something wrong with the code? or if I’m missing something.
If the questions already been answered, then please just say!
Thank you!
You probably want to do something like:
Note that the previous one converted the objects into string ( objects ) and the
convertto-htmlcmdlet produced the appropriate output.