主頁 > 知識庫 > PowerShell時間記錄腳本

PowerShell時間記錄腳本

熱門標(biāo)簽:真人和電話機(jī)器人對話 金融電銷公司怎么辦理外呼系統(tǒng) 使用電話機(jī)器人電銷是否違法 電話智能外呼系統(tǒng)誠信合作 湖州電銷防封卡 什么渠道可以找外呼系統(tǒng)客戶 雷霆電話機(jī)器人電話 安徽400電話辦理 信陽話務(wù)外呼系統(tǒng)怎么收費(fèi)

#initialization
   $timeInterval = 30 #監(jiān)測間隔
   $record = @{"Coding" = 0; "Outlook Email" = 0; "Gmail" = 0; "Google Reader" = 0; "BBS" = 0; "Other Internet" = 0; "Documents" = 0;}
  $count = 0
  $date = date -format "yyyyMMdd"
  #try to resume
  if (test-path "d:\temp\timeRecord$date.txt") {
    gc "d:\temp\timeRecord$date.txt" | % {if ($_ -match "\w+\s+\d+") {
      $groups = [Regex]::Match($_, "^(\w+\s?\w+)\s+(\d+)").Groups;
      $record[$groups[1].Value] = [int]::Parse($groups[2].Value);
    }}
  }
  #start to monitor
  while ($true)
  {
    $titles = ps | ? {$_.MainWindowTitle} | select MainWindowTitle
    $titles | % {
      if ($_ -match "Google 閱讀器 - Windows Internet Explorer") {$record["Google Reader"]++;}
      else {if ($_ -match "Gmail - Windows Internet Explorer") {$record["Gmail"]++;}
      else {if ($_ -match "Internet Explorer") {$record["Other Internet"]++;}
      else {if ($_ -match "Visual Studio") {$record["Coding"]++;}
      else {if ($_ -match "Microsoft Word") {$record["Documents"]++;}
      else {if ($_ -match "Microsoft Office OneNote") {$record["Documents"]++;}
      else {if ($_ -match "Microsoft PowerPoint") {$record["Documents"]++;}
      else {if ($_ -match "Message (HTML)") {$record["Outlook Email"]++;}
      else {if ($_ -match "bbs") {$record["BBS"]++;}
      }}}}}}}}
    }
    sleep($timeInterval)
    $count = ($count + 1) % 10 #為了防止數(shù)據(jù)丟失,每10次記錄寫入文件一次
    if ($count -eq 0) {$record > "d:\temp\timeRecord$date.txt"}
  }

為了解技術(shù)思路,研究了一下powershell.
整個開發(fā)與部署過程如下:

1.下載WindowsXP-KB926139-v2-x86-ENU

安裝powershell環(huán)境;

2.按照代碼要求,寫一個簡單的腳本;

3. 運(yùn)行powershell時,同 bat是有區(qū)別的.注意以下方法:

1) 解除限制:

set-executionpolicy Unrestricted

2) 將文件名保存為ps1
3) 通過以下方法運(yùn)行(假如文件名是c:a.ps1)
PS C:> .a
[@more@]

示例代碼:

function foo ( [int] $x)
{
$x = $x + 1
echo $x
}
foo (1 )

您可能感興趣的文章:
  • linux中 shell 歷史命令記錄功能
  • 用來記錄登錄后使用命令的shell腳本
  • PowerShell小技巧之定時記錄操作系統(tǒng)行為
  • shell將腳本輸出結(jié)果記錄到日志文件的實(shí)現(xiàn)
  • Powershell小技巧之記錄腳本的操作
  • Powershell小技巧之用變量累積記錄錯誤
  • shell如何記錄用戶的IP與命令詳解

標(biāo)簽:運(yùn)城 濟(jì)南 湛江 岳陽 鶴崗 德州 山南 六盤水

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《PowerShell時間記錄腳本》,本文關(guān)鍵詞  PowerShell,時間,記錄,腳本,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《PowerShell時間記錄腳本》相關(guān)的同類信息!
  • 本頁收集關(guān)于PowerShell時間記錄腳本的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章