E
E
Emil Revencu2021-08-26 14:04:33
Windows Server
Emil Revencu, 2021-08-26 14:04:33

How to programmatically find out the server reboot date to apply Updates?

How to programmatically (scripts or python) get server restart date to apply Updates?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Roman Bezrukov, 2021-08-26
@NortheR73

like this:
Get-WmiObject win32_operatingsystem | select csname, @{LABEL='LastBootUpTime';EXPRESSION={$_.ConverttoDateTime($_.lastbootuptime)}}
or
Get-CimInstance -ClassName win32_operatingsystem | select csname, lastbootuptime
or
Get-ComputerInfo | fl csname,oslastbootuptime
you can pull system logs for the following events:
1074 - System has been shutdown by a process/user
6005 - The Event log service was started
6006 - The Event log service was stopped
6008 - The previous system shutdown at time on date was unexpected
6013 - The system uptime is number seconds
Get-WinEvent -FilterHashtable @{logname = 'System'; id = 1074} -MaxEvents 3 | ft-wrap

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question