powershell - How to have both write -host and html -
i have written code snippet , have incorporated write host in want both write host , convert html run snippet can 1 me that.
$arrcomputers = get-content -path "c:\computers.txt" foreach ($strcomputer in $arrcomputers) { $colitems = get-wmiobject -class "win32_bios" -namespace "root\cimv2" ` -computername $strcomputer foreach ($objitem in $colitems) { write-host "computer name: " $strcomputer write-host "bios version: " $objitem.biosversion } $colitems1 = get-wmiobject -class win32_logicaldisk -filter "deviceid = 'c:'" -computername $strcomputer foreach ($objitem1 in $colitems1) { $e=$objitem1.freespace/1gb write-host "total space: " $e } $colitems4 = get-wmiobject -class win32_physicalmemory -computername $strcomputer $colitems5=$colitems4 | measure-object -property capacity -sum foreach ($objitem4 in $colitems5) { $e4=$colitems5.sum/1gb write-host "memory : " $e4 } }
you can use -fragment parameter.
$pcname = "computer name: $strcomputer" | convertto-html -fragment; $biosv = "bios version: $objitem.biosversion" | convertto-html -fragment; convertto-html -body "$pcname $biosv" -title "list of computers" | out-file c:\listofcomputers.html
just create variables after write-host same content , use converto-html @ end of script.
this way allows style html output using param tag or table tags have better layout clean sterile layout.
Comments
Post a Comment