How do I log startup and shut-down times in Windows 7?

Windows uses event logs with Event Viewer to log this sort of thing:

Event ID #6005 indicates system startup

Event ID #6006 indicates system shutdown

You should create a custom view in Event Viewer that will filter those two event IDs with the source being the eventlog.

This is the simplest way.

Alternatively, you can use PowerShell's Get-WinEvent cmdlet to create a custom filter and pipe those items to a text file.

Or... you can use the Get-EventLog to pipe a custom event log (that you create with the custom views...) to a text file.