Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Event Viewer Boot performance ID100 etc

$
0
0

Hi Scripting Guys,

Another question for you here....

I have a script to display boot performance for machines. I have been testing my script on Windows 7 and 8.1 and all works great!

We still have a number of XP workstations (slow migration) running and my script doesnt work because you can use the Get-Winevent on XP ahh!!

Could you take a look at the code and tell me if theres a way to get this working on XP... I can't even find the event in XP but I know your knowledge will guide me in the right direction.

$events = Get-WinEvent -FilterHashtable @{logname = "Microsoft-Windows-Diagnostics-Performance/Operational"}
#get the main details first
$eventtitle = $events[0]
$eventtitle |format-table -auto -wrap
#create ID value for file output
$id = $eventtitle | select-object ID 
# get the first event raw XML
$event = [xml]$events[0].ToXml()
# display its content
$event.Event.EventData.Data
#create table
$a = "<style>"
$a = $a + "BODY{background-color:White;}"
$a = $a + "TABLE{border-width: 1px;padding: 1px; border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:thistle}"
$a = $a + "TD{width:250px;border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
$a = $a + "</style>"
#Get-Service | Select-Object Status, Name, DisplayName | 
#Set export1 - this will be for the high detial
$export1 = $event.Event.EventData.Data |Select-Object Name, "#text"| ConvertTo-HTML -fragment
#set export2 -  this will be for the short detial
$export2 = $eventtitle  |Select-Object ID, Message| ConvertTo-HTML -fragment
#start the convert to html
ConvertTo-HTML -head $a -body  "<H2>Boot Infomation for ($env:computername) $(Get-Date -Format 'dd/MM/yyy HH:mm tt') </H2> $export2 <p> $export1" -Title "Details"| 
Out-File C:\Scripts\"Startup_($env:computername)_$(Get-Date -Format 'dd_MM_yyy HH_mm tt') $id.html"
#Invoke-Expression C:\Scripts\Bootinfo.html
#To just get one line of code user the following
#  $event.SelectSingleNode("//*[@Name='BootStartTime']")."#text"

Thanks in advance!!


Joe


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>