From f09075ad75ff18ff4bc4150e6341e7b23175d25c Mon Sep 17 00:00:00 2001 From: ratchetnclank Date: Fri, 29 Aug 2014 19:42:52 +0100 Subject: [PATCH] Added uptime and eventlog --- ServerInventory.ps1 | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/ServerInventory.ps1 b/ServerInventory.ps1 index 3e2411a..175ec1a 100644 --- a/ServerInventory.ps1 +++ b/ServerInventory.ps1 @@ -18,7 +18,7 @@ $MasterScriptVersion Set this location so that script can auto update on all ser #$ErrorActionPreference = "SilentlyContinue" #Some non fatal errors may occur uncomment this line if you don't want to display them. ######Variables to fill $MasterScriptVersion = "\\Server\share\ServerInventory.ps1" -$logo = "logo.png" +$logo = "Logo.png" $filepath = "\\someserver\someshare" $resourcedir = "./Resources" $enableschedtask = $true @@ -28,6 +28,7 @@ $Scriptdir = "C:\ServerInventory\" $sendemail = $false + ####### ## Email Setting if you would like to email the Results ###Edit as appropriate @@ -92,12 +93,25 @@ $osinfo = Get-WmiObject Win32_OperatingSystem -ComputerName $name | Select Capt $osinfo.InstallDate = [management.managementDateTimeConverter]::ToDateTime($osinfo.InstallDate) $osinfo | ConvertTo-html -Body "

Operating System Information

" >> "$filepath\$name.html" +###Uptime and Last BootVolume +$wmiPerfOsSystem = Get-WmiObject -computer $name -class Win32_PerfFormattedData_PerfOS_System +$wmiOS = Get-WmiObject -computer $name -class Win32_OperatingSystem +$lastBoot = $wmiOS.ConvertToDateTime($wmiOS.LastBootUpTime) +New-TimeSpan -seconds $wmiPerfOsSystem.SystemUpTime -ErrorAction SilentlyContinue |select days,hours,minutes,seconds | ConvertTo-html -body "

Uptime

" >> "$filepath\$name.html" +$lastBoot | select DateTime |ConvertTo-html -body "

Last Boot Time

" >> "$filepath\$name.html" + + ###Windows Updates last installed### $Updates = Get-ItemProperty -Path "Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\Results\Install" | select LastSuccessTime $Updates.LastSuccessTime = [DATETIME]::Parse($Updates.LastSuccessTime) $updatesout = New-Object -TypeName PSOBject $Updates | ConvertTo-Html -body "

Windows Updates Last Installed

" >> "$filepath\$name.html" +###Event log +Get-EventLog -LogName System -Newest 30 -EntryType Error,warning | select TimeGenerated,entrytype,source,message | ConvertTo-html -body "

System Events

" >> "$filepath\$name.html" +Get-EventLog -LogName Application -Newest 30 -EntryType Error,warning | select TimeGenerated,entrytype,source,message | ConvertTo-html -body "

Application Events

" >> "$filepath\$name.html" + + ##Time Zone## Get-WmiObject win32_TimeZone -ComputerName $name | Select caption | ConvertTo-html -Body "

Time Zone

" >> "$filepath\$name.html"