Hi Scripting Guys,
I have wrote some code which takes the details regarding boot times from the event logs and outputs them into a table in htm.
BUT - I'm having trouble with my powershell sript, it runs fine when I am running powershell as admin, but when I try to run it as a standard user it doesn't work.
I get the Message -
Get-WinEvent : No events were found that match the specified selection criteria.
I know this is because the event log that I am trying to get details for is requiring admin rights - but I want to deploy this to users without admin rights. HELP! is this possible? I am not trying to break UAC to get it working, I just want to know if there is another option to get the detail or this method can be used some other way.
My script -
$events = Get-WinEvent -FilterHashtable @{logname="Microsoft-Windows-Diagnostics-Performance/Operational"; id=100}
# get the first event raw XML
$event = [xml]$events[0].ToXml()
# display its content
$event.Event.EventData.Data
$a = "<style>"
$a = $a + "BODY{background-color:White;}"
$a = $a + "TABLE{border-width: 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{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color:PaleGoldenrod}"
$a = $a + "</style>"
#Get-Service | Select-Object Status, Name, DisplayName |
$event.Event.EventData.Data | select-object name, "#text" |
ConvertTo-HTML -head $a -body "<H2>Boot Infomation for $env:computername</H2>"|
Out-File C:\Scripts\Bootinfo.htm
#Invoke-Expression C:\Scripts\Bootinfo.htmThe script does the following, gets the last winevent for boot time - converts it to XML to get the detail - outputs it to a htm file - also displaying the PC name.
It does exactly what I want (for now) later I want to extract details into an SQL server - but one thing at a time.
Thank you in advance
Joe
PowerShell experience - 5 weeks in counting!