| Mark's profileMark Sheppard's SpaceBlogLists | Help |
|
January 02 PowerShell System UptimeI just needed to know how long it was since my box was last rebooted. Windows Vista has a nice feature where this is now a property of the Performance tab in Task Manager. But alas, there's no such nice functionality in Windows 2K3. Usually I end up in PerfMon to get the number of seconds the box has been up and then in calculator to convert this into real time. Enter PowerShell to the rescue: function GLOBAL:Get-SystemBootupTime([String]$computer="localhost") { Not bad, I can now see the system uptime in seconds, but I want the result formatted function GLOBAL:Get-SystemUptimeFormatted([String]$computer="localhost") { Job done! As a developer, I tend towards using .NET all over, so I've probably missed some rather subtle ways of achieving the formatting with PowerShell. You can get a lot of other useful information from the WMI classes that could be the focus of other functions: PS C:\> $computer = "localhost" To ensure that this handy set of functions is always there when needed, I've added them to my profile: PS C:\> Notepad $profile
Comments (3)
Trackbacks (1)The trackback URL for this entry is: http://mark-sheppard.spaces.live.com/blog/cns!1905A40C83BF050F!150.trak Weblogs that reference this entry
|
|
|