Skip to content

Commit f09075a

Browse files
committed
Added uptime and eventlog
1 parent 4290292 commit f09075a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

ServerInventory.ps1

+15-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ $MasterScriptVersion Set this location so that script can auto update on all ser
1818
#$ErrorActionPreference = "SilentlyContinue" #Some non fatal errors may occur uncomment this line if you don't want to display them.
1919
######Variables to fill
2020
$MasterScriptVersion = "\\Server\share\ServerInventory.ps1"
21-
$logo = "logo.png"
21+
$logo = "Logo.png"
2222
$filepath = "\\someserver\someshare"
2323
$resourcedir = "./Resources"
2424
$enableschedtask = $true
@@ -28,6 +28,7 @@ $Scriptdir = "C:\ServerInventory\"
2828
$sendemail = $false
2929

3030

31+
3132
#######
3233
## Email Setting if you would like to email the Results
3334
###Edit as appropriate
@@ -92,12 +93,25 @@ $osinfo = Get-WmiObject Win32_OperatingSystem -ComputerName $name | Select Capt
9293
$osinfo.InstallDate = [management.managementDateTimeConverter]::ToDateTime($osinfo.InstallDate)
9394
$osinfo | ConvertTo-html -Body "<H2> Operating System Information </H2>" >> "$filepath\$name.html"
9495

96+
###Uptime and Last BootVolume
97+
$wmiPerfOsSystem = Get-WmiObject -computer $name -class Win32_PerfFormattedData_PerfOS_System
98+
$wmiOS = Get-WmiObject -computer $name -class Win32_OperatingSystem
99+
$lastBoot = $wmiOS.ConvertToDateTime($wmiOS.LastBootUpTime)
100+
New-TimeSpan -seconds $wmiPerfOsSystem.SystemUpTime -ErrorAction SilentlyContinue |select days,hours,minutes,seconds | ConvertTo-html -body "<H2>Uptime</H2>" >> "$filepath\$name.html"
101+
$lastBoot | select DateTime |ConvertTo-html -body "<H2>Last Boot Time</H2>" >> "$filepath\$name.html"
102+
103+
95104
###Windows Updates last installed###
96105
$Updates = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install" | select LastSuccessTime
97106
$Updates.LastSuccessTime = [DATETIME]::Parse($Updates.LastSuccessTime)
98107
$updatesout = New-Object -TypeName PSOBject
99108
$Updates | ConvertTo-Html -body "<H2>Windows Updates Last Installed</H2>" >> "$filepath\$name.html"
100109

110+
###Event log
111+
Get-EventLog -LogName System -Newest 30 -EntryType Error,warning | select TimeGenerated,entrytype,source,message | ConvertTo-html -body "<H2>System Events</H2>" >> "$filepath\$name.html"
112+
Get-EventLog -LogName Application -Newest 30 -EntryType Error,warning | select TimeGenerated,entrytype,source,message | ConvertTo-html -body "<H2>Application Events</H2>" >> "$filepath\$name.html"
113+
114+
101115
##Time Zone##
102116
Get-WmiObject win32_TimeZone -ComputerName $name | Select caption | ConvertTo-html -Body "<H2> Time Zone </H2>" >> "$filepath\$name.html"
103117

0 commit comments

Comments
 (0)