Board logo

标题: [转载代码] PowerShell窗口动态显示当前系统时间 [打印本页]

作者: PS2.0    时间: 2017-7-31 10:35     标题: PowerShell窗口动态显示当前系统时间

  1. $code =
  2. {
  3.     # submit the host process RawUI interface and the execution context
  4.     param($RawUi)
  5.     do
  6.     {
  7.         # compose the time and date display
  8.         $time = Get-Date -UFormat "%Y-%m-%d %H:%M:%S"
  9.         # compose the title bar text
  10.         $title = "Current Time: $time"
  11.         # output the information to the title bar of the host process
  12.         $RawUI.WindowTitle = $title
  13.         # wait a half second
  14.         Start-Sleep -Milliseconds 500
  15.     } while ($true)
  16. }
  17. $ps = [PowerShell]::Create()
  18. $null = $ps.AddScript($code).AddArgument($host.UI.RawUI)
  19. $handle = $ps.BeginInvoke()
复制代码


http://community.idera.com/powershell/powertips/b/tips/posts/adding-live-clock-to-powershell-title-bar-part-1




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2