Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Trouble with convertto-html

$
0
0

Hi,

Relatively new to Powershell and while I am finding my way around the console and exporting to file formats easy to grasp, the html feature is confusing the hell out of me.

Hoping to get some guidance on a best approach to export a loop to a html page and then have the page refresh or close/reopen.

 

The code

 

function StratusCodes { param ( [string] $State ) switch ($State) { 65536 { return 'Empty' } 131073 { return 'Remoted from Svc' } 131074 { return 'Shot' } 131075 { return 'Broken' } 131076 { return 'Dumping' } 262149 { return 'Diagnostics' } 131078 { return 'Diags Passed' } 131079 { return 'Initializing' } 131080 { return 'Syncing' } 131081 { return 'F/W Updating' } 131088 { return 'F/W Updating Done' } 131082 { return 'Offline' } 131083 { return 'Device Ready' } 131084 { return 'Stopped' } 524308 { return 'Online' } 524309 { return 'Simplex' } 1572886 { return 'Duplex' } 1572887 { return 'Triplex' } 65560 { return 'Not Present' } default { return 'No Data' } } } Import-csv C:\serverlist.csv | ForEach-object { $Name = $_.Name $cpu0 = get-wmiobject SRA_CPUBoard -ComputerName $Name -filter 'InstanceName=0' | select-object -expandproperty OperationalState $cpu1 = get-wmiobject SRA_CPUBoard -ComputerName $Name -filter 'InstanceName=1' | select-object -expandproperty OperationalState $ilo0 = get-wmiobject SRA_IOBoard -ComputerName $Name -filter 'InstanceName=10' | select-object -expandproperty OperationalState $ilo1 = get-wmiobject SRA_IOBoard -ComputerName $Name -filter 'InstanceName=11' | select-object -expandproperty OperationalState $cpu0output = StratusCodes -State $cpu0.State $cpu1output = StratusCodes -State $cpu1.State $ilo0output = StratusCodes -State $ilo0.State $ilo1output = StratusCodes -State $ilo1.State
write-host "$Name,$cpu0output,$cpu1output,$ilo0output,$ilo1output" }

 

 

Output to screen looks like this

Server1,Duplex,Duplex,Duplex,Duplex

Server2,Duplex,Duplex,Duplex,Duplex

Server3,No Data,No Data,No Data,No Data

Server4,Duplex,Duplex,Duplex,Duplex

Server5,Duplex,Duplex,Duplex,Duplex

 

Output to text file inside the loop "| out-file c:\test.txt"

Server5,Duplex,Duplex,Duplex,Duplex

 

Output to text file inside the loop "| out-file c:\test.txt -append" File will need to be deleted each time.

Server1,Duplex,Duplex,Duplex,Duplex

Server2,Duplex,Duplex,Duplex,Duplex

Server3,No Data,No Data,No Data,No Data

Server4,Duplex,Duplex,Duplex,Duplex

Server5,Duplex,Duplex,Duplex,Duplex

 

Output to html file inside the loop "| convertto-html | out-file c:\test.htm -append" File will need to be deleted each time.

 

34

 

*
34
*
34
*
34
*
34
*
34
*

 

34

 

 

All I am trying to achieve is output the results to html page.

Headings and columns would be amazing, but right now I am just trying to get my head around how I export these results to html.

Any help is greatly appreciated.


Viewing all articles
Browse latest Browse all 6937

Trending Articles