$oIE=new-object -com internetexplorer.application $oIE.navigate2("About:blank") while ($oIE.busy) { sleep -milliseconds 50 } $oIE.visible=$true $procList=ps |select-object ProcessName,Handles,NPM,PM,WS,VM,CPU,Id |convertto-html $oDocBody=$oIE.document.documentelement.lastchild ; #populate the document.body $oDocBody.innerhtml=$procList $oDocBody.style.font="12pt Arial"; $oIE.document.bgcolor="#D7D7EA" #Reading back from IE. $oTBody=@($oIE.document.getElementsByTagName("TBODY"))[0] ; foreach ($oRow in $oTBody.childNodes) { #check the 4 column(WS),and highlight it if it is greater than 5MB. $WS=(@($oRow.childNodes)[4].innerhtml) -as [int] ; if (($ws -ne $null) -and ($WS -ge 5mb)) { $oRow.bgColor="#AAAAAA" ; } } #Prepare a title. $oTitle=$oIE.document.createElement("P") $oTitle.style.font="bold 20pt Arial" $oTitle.innerhtml="Process List"; $oTitle.align="center" ; #Display the title before the Table object. $oTable=@($oIE.document.getElementsByTagName("TABLE"))[0] ; $oDocBody.insertBefore($oTitle,$oTable) > $null;
Sunday, May 30, 2010
Sample of Powershell usage for displaying in IE
Labels:
Windows Automation
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment