Advertisement
Guest User

Untitled

a guest
Jan 20th, 2013
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. #
  3. # show-uptime.ps1
  4. #
  5.  
  6. $uptime = @{}
  7.  
  8. gwmi win32_operatingsystem | % {
  9.  
  10.     $uptime.OS = $_.caption
  11.     $uptime.VER = $_.version
  12.     $uptime.SP = $_.servicepackmajorversion
  13.     $uptime.INS = ([wmi]'').converttodatetime((gwmi win32_operatingsystem).installdate)
  14.    
  15.     new-timespan -st ([wmi]'').converttodatetime((gwmi win32_operatingsystem).lastbootuptime) -en $( get-date ) | % {
  16.  
  17.     $uptime.UP = '{0:00} days, {1:00}:{2:00}:{3:00}' -f $_.days,$_.hours,$_.minutes,$_.seconds
  18.  
  19.     }
  20.  
  21. }
  22.  
  23. new-object -t psobject -p $uptime | fl OS,VER,SP,INS,UP
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement