Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.
Keywords: Convert Process List HTM HTML System.Management.Automation System.Management.Automation.PowerShell Get-Process Get-Service ConvertTo-Html Set-Content Converts PowerShell cmdlet
;*************************************************************************** ;** Get-Process or Get-Service then Convert to HTML ;** ;** Purpose: Retrieves information about all the processes running on the computer and ;** creates and display an HTML table ;** ;** Inputs: PowerShell Command with Set-Content ;** Outputs: Results in a WIL Dialog ;** Reference: ;** REQUIRES WinBatch 2013A or newer ;** ;** Developers: Deana Falk 2013.05.28 Initial ;** Stan Littlefield 2013.05.29 Added HTML formatting ;*************************************************************************** If Version( )< '2013A' Pause('Notice', 'Need 2013A or Newer Version of WinBatch') Exit EndIf ;*************************************************************************** ;** Get-Process ;*************************************************************************** PSCmd = `Get-Process | ConvertTo-Html -head $a | Set-Content ` ;*************************************************************************** ;** Get-Service ;*************************************************************************** PSCmd = `Get-Service | Select-Object Status, Name, DisplayName | ConvertTo-Html -head $a | Set-Content ` strHTMLFile = DirScript():"ProcessList.html" ; Output file if FileExist( strHTMLFile ) then FileDelete( strHTMLFile ) ; Powershell Code cScript = '$a = "<style>"':@CRLF cScript = cScript:'$a = $a + "BODY{background-color:peachpuff;}"':@CRLF cScript = cScript:'$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"':@CRLF cScript = cScript:'$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"':@CRLF cScript = cScript:'$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:palegoldenrod}"':@CRLF cScript = cScript:'$a = $a + "</style>"':@CRLF cScript = cScript : PSCmd : strHTMLFile BoxOpen("Please Wait","Processing... ") ObjectClrOption("use", "System.Management.Automation,version=1.0.0.0,publicKeyToken=31bf3856ad364e35,culture=neutral") objAutoPs = ObjectClrNew("System.Management.Automation.PowerShell") oPshell = objAutoPs.Create() oScope = ObjectType("BOOL",@TRUE) oPshell.AddScript(cScript,oScope) objAsync = oPshell.BeginInvoke() oPShell.EndInvoke(objAsync) oPshell.Dispose() oPshell=0 BoxShut() If !FileExist( strHTMLFile ) Display(2, "File Not Created", strHTMLFile ) Exit Endif MyDialogFormat=`WWWDLGED,6.2` MyDialogCaption=`Process List` MyDialogX=002 MyDialogY=059 MyDialogWidth=766 MyDialogHeight=353 MyDialogNumControls=003 MyDialogProcedure=`DEFAULT` MyDialogFont=`DEFAULT` MyDialogTextColor=`DEFAULT` MyDialogBackground=`DEFAULT,DEFAULT` MyDialogConfig=0 MyDialog001=`231,333,036,012,PUSHBUTTON,"PushButton_OK",DEFAULT,"OK",1,10,32,DEFAULT,DEFAULT,DEFAULT` MyDialog002=`499,333,036,012,PUSHBUTTON,"PushButton_Cancel",DEFAULT,"Cancel",0,20,DEFAULT,DEFAULT,DEFAULT,DEFAULT` MyDialog003=`033,023,696,298,COMCONTROL,"ComControl_1",DEFAULT,"`:strHTMLFile:`",DEFAULT,30,DEFAULT,DEFAULT,DEFAULT,DEFAULT` ButtonPushed=Dialog("MyDialog") Exit
Article ID: W17830
Filename: ConvertTo-HTML.txt
File Created: 2013:05:29:10:07:04
Last Updated: 2013:05:29:10:07:04