ActiveXperts Network Monitor
Monitor servers, workstations, devices and applications in your network

Quicklinks


NOTE: ActiveXperts Network Monitor ships with a large collection of PowerShell scripts to monitor any aspect of your network. Most PowerShell scripts also have a VBScript implementation. Download Now »


ConvertTo-Html - Powershell CmdLet

Microsoft Windows PowerShell is a command-line shell and scripting tool based on the Microsoft .NET Framework. It is designed for system administrators, engineers and developers to control and automate the administration of Windows and applications.

More than hundred command-line tools (so called "cmdlets") can be used to perform system administration tasks and Windows Management Instrumentation (WMI). These cmdlets are easy to use, with standard naming conventions and common parameters, and standard tools for piping, sorting, filtering, and formatting data and objects.

ConvertTo-Html


Description
Convert the input into an HTML table

Usage
ConvertTo-Html [[-property] Object[] ]
         [-inputObject psobject]
            [-body string[] ]  [-head string[] ] [-title string]
               [CommonParameters]

Options
-inputObject psobject
        The objects to represent as an HTML table. 
        A variable that contains the objects or a command/expression
        that gets the objects.

    -property Object
        Properties of the input object to appear in the HTML table.
        
    -body string
        Text to include in the  element of the HTML.

    -head string
        Text to include in the  element of the HTML output.
        
    -title string
        Text to include in the  element of the HTML output.

    CommonParameters
        The common parameters: -Verbose, -Debug,-ErrorAction, -ErrorVariable, -OutVariable

<u>Example(s)</u>
Display the date as HTML on the console :

PS C:\>get-date | convertto-html

Save the system processes to C:\processes.html

PS C:\>Get-Process | ConvertTo-Html name,path,fileversion | Set-Content c:\processes.htm

Save the system services to C:\services.html

PS C:\>get-service | ConvertTo-Html -Title "Services" -Body "<H2>The result of get-service</H2> " -Property Name,Status  >  c:\services.html

Save the system services to C:\services.html and format in color:

PS C:\>get-service | ConvertTo-Html -Title "Services" -Body "<H2>The result of get-service</H2> " -Property Name,Status |
foreach {if($_ -like "*<td>Running</td>*"){$_ -replace "<tr>", "<tr bgcolor=green>"}elseif($_ -like "*<td>Stopped</td>*"){$_ -replace "<tr>", "<tr bgcolor=red>"}else{$_}}   >  c:\services.html

</pre>


    </div><!-- /page -->
  </div><!-- /contents -->
  
  <div id="footer" class="clear">
    <div id="footer_x"><!-- --></div>
      <div id="footernav">
        <p class="nocss">Footer Navigation</p>
        <ul>
          <li class="first">© 2012 <a href="#header" title="Top">Active<span class="x">X</span>perts Software B.V.</a> All rights reserved.</li>
          <li><a href="/sitemap/" title="">Site Map</a></li>          
          <li><a href="/activexperts/contact/" title="">Contact Us</a></li>
          <li><a href="/activexperts/termsofuse/" title="">Terms of Use</a></li>
          <li class="last"><a href="/activexperts/privacypolicy/" title="">Privacy Policy</a></li>
        </ul>
      </div><!-- /footernav -->
    </div><!-- /footer -->
  </div><!-- Wrapper -->
</body>
</html>