{"id":17421,"date":"2010-08-15T00:01:00","date_gmt":"2010-08-15T00:01:00","guid":{"rendered":"https:\/\/blogs.technet.microsoft.com\/heyscriptingguy\/2010\/08\/15\/using-powershell-to-format-a-report-from-xml-data\/"},"modified":"2010-08-15T00:01:00","modified_gmt":"2010-08-15T00:01:00","slug":"using-powershell-to-format-a-report-from-xml-data","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/scripting\/using-powershell-to-format-a-report-from-xml-data\/","title":{"rendered":"Using PowerShell to Format a Report from XML Data"},"content":{"rendered":"<p><b>Summary<\/b>: Use Windows PowerShell to create a formatted report from data stored in XML files.<\/p>\n<p>&nbsp;<\/p>\n<p>Microsoft Scripting Guy Ed Wilson here. It is still dark outside, and the lights of the neighborhood are slowly beginning to come on. It is <i>really<\/i> humid this morning. I am sitting at the kitchen table with my laptop checking comments that were posted to the <a href=\"http:\/\/blogs.technet.com\/heyscriptingguy\/\">Hey, Scripting Guy! Blog<\/a>. When I was talking to my friends in <a href=\"http:\/\/en.wikipedia.org\/wiki\/Australia\">Australia<\/a> the other day, they were complaining that it was only 5 degrees Celsius (41 degrees Fahrenheit). To me that sounds great (the weather guesser is predicting 37 degrees Celsius&mdash;100 degrees Fahrenheit today).<\/p>\n<p><a href=\"http:\/\/blogs.technet.com\/b\/heyscriptingguy\/archive\/2010\/08\/14\/weekend-scripter-using-group-policy-to-deploy-a-windows-powershell-logon-script.aspx\">Yesterday<\/a>, I talked with you about using <a href=\"http:\/\/technet.microsoft.com\/en-us\/windowsserver\/bb310732.aspx\">Group Policy<\/a> to deploy the script I wrote to collect process information. <\/p>\n<p>The GPO has now had time to replicate among my various domain controllers and has updated the various workstations on my network (doesn&rsquo;t everyone have multiple domain controllers at home?). The network share that is collecting the XML files that are produced via this logon process is shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4760.wes081510011_10388A8B.jpg\"><img decoding=\"async\" height=\"424\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4670.wes081510011_thumb_4E51A53C.jpg\" alt=\"Image of network share collecting XML files\" border=\"0\" title=\"Image of network share collecting XML files\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" \/><\/a> <\/p>\n<p>Because the entire point of this exercise is to reduce the amount of manual work involved in examining startup processes, I realized I needed to write a script that would automatically process the XML files for me. The ParseProcesses.ps1 script is shown here. <\/p>\n<p style=\"padding-left: 30px\"><strong>ParseProcesses.ps1<\/strong><\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #0000ff\">Get-ChildItem<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-path<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">\\\\hyperv-box\\shared<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Include<\/span><span style=\"color: #808080\"> &#8220;Process*.xml&#8221; <\/span><span style=\"color: #000000\">-Recurse<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #0000ff\">ForEach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #0000ff\">New-Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.baseName<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000ff\">Import-Clixml<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-path<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.FullName)<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <br \/>&#8220;Getting startup time:&#8221; <br \/><\/span><span style=\"color: #0000ff\">Get-Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Process1*<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #0000ff\">ForEach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #2b91af\">$v1<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">New-Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\"> &#8220;$($_.name.substring(9))Smss&#8221; <\/span><span style=\"color: #000000\">-Value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">where-object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">-eq<\/span><span style=\"color: #808080\"> &#8220;smss&#8221;<\/span><span style=\"color: #000000\">})<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-passthru<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #2b91af\">$v2<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">New-Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\"> &#8220;$($_.name.substring(9))Search&#8221; <\/span><span style=\"color: #000000\">-Value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">Where-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">-eq<\/span><span style=\"color: #808080\"> &#8220;SearchIndexer&#8221;<\/span><span style=\"color: #000000\">})<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-passthru<\/span><span style=\"color: #808080\"> <br \/>&#8220;$($_.name.substring(9)) start time $( $($v2.value.startTime) &#8211;&nbsp; <br \/>$($v1.value.startTime) )&#8221; <br \/>&#8220;Startup process order:&#8221; <br \/><\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.Value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Sort-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">startTime<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #0000ff\">Format-Table<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">name,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">starttime<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-AutoSize<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <br \/>&#8220;Listing Process counts:&#8221; <br \/><\/span><span style=\"color: #0000ff\">Get-Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">process*<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Sort-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #0000ff\">Format-Table<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">name,<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">@{LABEL<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&#8220;count&#8221;<\/span><span style=\"color: #0000ff\">;<\/span><span style=\"color: #000000\">EXPRESSION<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.value.count}<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-autosize<\/span><span style=\"color: #808080\"> <br \/>&#8220;Getting the late starting processes from point 4&#8221; <br \/><\/span><span style=\"color: #0000ff\">Get-Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">process4*<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">ForEach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/>&#8220;$($_.name.substring(9))&#8221; <br \/><\/span><span style=\"color: #2b91af\">$task<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Where-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">-eq<\/span><span style=\"color: #808080\"> &#8216;taskhost&#8217;<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Where-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.startTime<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">-gt<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$task<\/span><span style=\"color: #000000\">.startTime<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #0000ff\">Sort-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">company<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">Format-Table<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">name,company,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">product,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">starttime<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-AutoSize<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #2b91af\">$task<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$null<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">}<\/span> <\/p>\n<p>The ParseProcesses.ps1 script begins by obtaining a listing of all the XML files in the \\\\hyperv-box\\shared folder that begin with the Word <b>Process<\/b>. It then creates a new variable using the <b>baseName<\/b> of the file that contains the reconstituted process object. This section of the script is shown here: <\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #0000ff\">Get-ChildItem<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-path<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">\\\\hyperv-box\\shared<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Include<\/span><span style=\"color: #808080\"> &#8220;Process*.xml&#8221; <\/span><span style=\"color: #000000\">-Recurse<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #0000ff\">ForEach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #0000ff\">New-Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.baseName<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #0000ff\">Import-Clixml<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-path<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.FullName)<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">}<\/span> <\/p>\n<p>The next section of the script is a bit jumbled. After displaying a message about getting the startup time, the script gets every variable that begins with the name <b>Process1<\/b>. These will be the first data points <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/ee198910.aspx\">for each<\/a> computer that has data stored in the folder. Now a new variable is created that contains only an SMSS process object. Next, a new variable is created that only contains a <b>SearchIndexer<\/b> process object. The <b>starttime<\/b> of the SMSS process is subtracted from the <b>starttime<\/b> of the <b>SearchIndexer<\/b> process, and the result is displayed. Next, a sorted list of all processes from the first process snapshot is displayed in a table. This section of the script is shown here:<\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #808080\">&#8220;Getting startup time:&#8221; <br \/><\/span><span style=\"color: #0000ff\">Get-Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">Process1*<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #0000ff\">ForEach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #2b91af\">$v1<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">New-Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\"> &#8220;$($_.name.substring(9))Smss&#8221; <\/span><span style=\"color: #000000\">-Value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">where-object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">-eq<\/span><span style=\"color: #808080\"> &#8220;smss&#8221;<\/span><span style=\"color: #000000\">})<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-passthru<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #2b91af\">$v2<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">New-Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\"> &#8220;$($_.name.substring(9))Search&#8221; <\/span><span style=\"color: #000000\">-Value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">(<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">Where-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">-eq<\/span><span style=\"color: #808080\"> &#8220;SearchIndexer&#8221;<\/span><span style=\"color: #000000\">})<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-passthru<\/span><span style=\"color: #808080\"> <br \/>&#8220;$($_.name.substring(9)) start time $( $($v2.value.startTime) &#8211;&nbsp; <br \/>$($v1.value.startTime) )&#8221; <br \/>&#8220;Startup process order:&#8221; <br \/><\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.Value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Sort-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">startTime<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #0000ff\">Format-Table<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">name,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">starttime<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-AutoSize<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">}<\/span> <\/p>\n<p>This portion of the report is shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1537.wes081510021_26AB2912.jpg\"><img decoding=\"async\" height=\"432\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/1033.wes081510021_thumb_1F1FB9A5.jpg\" alt=\"Image of portion of script\" border=\"0\" title=\"Image of portion of script\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" \/><\/a> <\/p>\n<p>A table listing the process counts from each of the process snapshots is created. The table uses a custom column that displays a count of the processes. This is shown here:<\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #808080\">&#8220;Listing Process counts:&#8221; <br \/><\/span><span style=\"color: #0000ff\">Get-Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">process*<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Sort-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #0000ff\">Format-Table<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">name,<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #000000\">@{LABEL<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&#8220;count&#8221;<\/span><span style=\"color: #0000ff\">;<\/span><span style=\"color: #000000\">EXPRESSION<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.value.count}<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-autosize<\/span> <\/p>\n<p>The process counts portion of the report is shown in the following image.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6242.wes081510031_45819CF0.jpg\"><img decoding=\"async\" height=\"432\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6648.wes081510031_thumb_19D0D2F4.jpg\" alt=\"Image of process counts portion of report\" border=\"0\" title=\"Image of process counts portion of report\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" \/><\/a> <\/p>\n<p>The last thing that is done is to look at all the processes that start up during the final process snapshot. The <b>taskhost<\/b> process is used as the starting point for this list. The processes, the starttime, the company name, and product name are all listed in a table. This section of the code is shown here:<\/p>\n<p style=\"padding-left: 30px\"><span style=\"color: #808080\">&#8220;Getting the late starting processes from point 4&#8221; <br \/><\/span><span style=\"color: #0000ff\">Get-Variable<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">process4*<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">ForEach-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\"> <br \/>&#8220;$($_.name.substring(9))&#8221; <br \/><\/span><span style=\"color: #2b91af\">$task<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Where-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.name<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">-eq<\/span><span style=\"color: #808080\"> &#8216;taskhost&#8217;<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.value<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">Where-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">{<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$_<\/span><span style=\"color: #000000\">.startTime<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">-gt<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$task<\/span><span style=\"color: #000000\">.startTime<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">}<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #0000ff\">Sort-Object<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">company<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">|<\/span><span style=\"color: #808080\">&nbsp; <br \/><\/span><span style=\"color: #0000ff\">Format-Table<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-Property<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">name,company,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">product,<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">starttime<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #000000\">-AutoSize<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #2b91af\">$task<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #0000ff\">=<\/span><span style=\"color: #808080\">&nbsp;<\/span><span style=\"color: #2b91af\">$null<\/span><span style=\"color: #808080\"> <br \/><\/span><span style=\"color: #000000\">}<\/span> <\/p>\n<p>The process table report from this portion of the script is shown here.<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/6330.wes081510041_7D53E113.jpg\"><img decoding=\"async\" height=\"432\" width=\"604\" src=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/29\/2019\/02\/4744.wes081510041_thumb_3CB194A4.jpg\" alt=\"Image of process table report\" border=\"0\" title=\"Image of process table report\" style=\"border-bottom: 0px;border-left: 0px;border-top: 0px;border-right: 0px\" \/><\/a> <\/p>\n<p>Join us tomorrow as we begin User Management Week. We invite you to follow us on <a href=\"http:\/\/bit.ly\/scriptingguystwitter\">Twitter<\/a> and <a href=\"http:\/\/bit.ly\/scriptingguysfacebook\">Facebook<\/a>. If you have any questions, send email to us at <a href=\"mailto:scripter@microsoft.com\">scripter@microsoft.com<\/a>, or post your questions on the <a href=\"http:\/\/social.technet.microsoft.com\/Forums\/en\/ITCG\/threads\/\">Official Scripting Guys Forum<\/a>. See you tomorrow. Until then, peace.<\/p>\n<p>&nbsp;<\/p>\n<p><b>Ed Wilson and Craig Liebendorfer, Scripting Guys<\/b><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Summary: Use Windows PowerShell to create a formatted report from data stored in XML files. &nbsp; Microsoft Scripting Guy Ed Wilson here. It is still dark outside, and the lights of the neighborhood are slowly beginning to come on. It is really humid this morning. I am sitting at the kitchen table with my laptop [&hellip;]<\/p>\n","protected":false},"author":595,"featured_media":87096,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[25,31,87,3,4,61,45],"class_list":["post-17421","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-scripting","tag-displaying-output","tag-operating-system","tag-processes","tag-scripting-guy","tag-scripting-techniques","tag-weekend-scripter","tag-windows-powershell"],"acf":[],"blog_post_summary":"<p>Summary: Use Windows PowerShell to create a formatted report from data stored in XML files. &nbsp; Microsoft Scripting Guy Ed Wilson here. It is still dark outside, and the lights of the neighborhood are slowly beginning to come on. It is really humid this morning. I am sitting at the kitchen table with my laptop [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/17421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/users\/595"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/comments?post=17421"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/posts\/17421\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media\/87096"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/media?parent=17421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/categories?post=17421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/scripting\/wp-json\/wp\/v2\/tags?post=17421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}