最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PowerShell時(shí)間記錄腳本

 更新時(shí)間:2015年09月15日 09:01:53   投稿:hebedich  
這篇文章主要介紹了PowerShell時(shí)間記錄腳本的相關(guān)資料,非常簡(jiǎn)單實(shí)用,需要的朋友可以參考下

#initialization
   $timeInterval = 30 #監(jiān)測(cè)間隔
   $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.
整個(gè)開發(fā)與部署過程如下:

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

安裝powershell環(huán)境;

2.按照代碼要求,寫一個(gè)簡(jiǎn)單的腳本;

3. 運(yùn)行powershell時(shí),同 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 )

相關(guān)文章

  • PowerShell 3.0管理Hyper-V 3.0

    PowerShell 3.0管理Hyper-V 3.0

    這篇文章主要介紹了PowerShell 3.0管理Hyper-V 3.0的相關(guān)資料,非常的詳細(xì),需要的朋友可以參考下
    2015-09-09
  • Windows Powershell 執(zhí)行外部命令

    Windows Powershell 執(zhí)行外部命令

    Windows PowerShell 在使用方面與 Cmd.exe 并無多大不同,只是 Windows PowerShell 的功能更為強(qiáng)大。與 Cmd.exe 一樣,Windows PowerShell 具有內(nèi)置的腳本編寫語言,不過它比 Cmd.exe 原始的批處理語言更為靈活。Cmd.exe 做到的事情,Windows PowerShell 幾乎都能做到。
    2014-08-08
  • PowerShell 自動(dòng)備份oracle并上傳到ftp

    PowerShell 自動(dòng)備份oracle并上傳到ftp

    我這里有這樣一個(gè)需求:有一個(gè)數(shù)據(jù)庫,每天使用SQL Server Agent自動(dòng)生成備份文件。然后,這個(gè)數(shù)據(jù)庫非常重要,需要把每天的備份上傳一個(gè)遠(yuǎn)程的FTP服務(wù)器上去。下面我們來看看如何使用Powershell來實(shí)現(xiàn)吧
    2015-08-08
  • powershell常用命令大全

    powershell常用命令大全

    PowerShell是強(qiáng)大的自動(dòng)化工具,涵蓋服務(wù)管理、事件日志查詢、變量操作、腳本執(zhí)行、遠(yuǎn)程管理以及模塊管理等,本文介紹powershell常用命令大全,感興趣的朋友一起看看吧
    2025-02-02
  • Powershell實(shí)現(xiàn)捕獲系統(tǒng)內(nèi)置EXE程序的異常

    Powershell實(shí)現(xiàn)捕獲系統(tǒng)內(nèi)置EXE程序的異常

    這篇文章主要介紹了Powershell實(shí)現(xiàn)捕獲系統(tǒng)內(nèi)置EXE程序的異常,系統(tǒng)內(nèi)置的EXE程序是指如robocopy.exe、ipconfig.exe等命令的實(shí)現(xiàn)程序,需要的朋友可以參考下
    2014-12-12
  • PowerShell面向?qū)ο缶幊袒A(chǔ)知識(shí)總結(jié)

    PowerShell面向?qū)ο缶幊袒A(chǔ)知識(shí)總結(jié)

    這篇文章主要介紹了PowerShell面向?qū)ο缶幊袒A(chǔ)知識(shí)總結(jié),本文著重講解面向?qū)ο蟮囊恍└拍?又給出了Get-Member命令輸出類的屬性和方法的例子,需要的朋友可以參考下
    2014-08-08
  • Windows Powershell 介紹和安裝

    Windows Powershell 介紹和安裝

    Powershell 是運(yùn)行在windows機(jī)器上實(shí)現(xiàn)系統(tǒng)和應(yīng)用程序管理自動(dòng)化的命令行腳本環(huán)境。微軟之所以將Powershell 定位為Power,并不是夸大其詞,因?yàn)樗耆С謱?duì)象。其可讀性,易用性,可以位居當(dāng)前所有shell之首。
    2014-08-08
  • 使用 powershell 創(chuàng)建虛擬機(jī)

    使用 powershell 創(chuàng)建虛擬機(jī)

    Azure PowerShell 模塊用于從 PowerShell 命令行或腳本創(chuàng)建和管理 Azure 資源。 本指南詳細(xì)介紹了如何使用 Azure PowerShell 模塊創(chuàng)建虛擬機(jī)。
    2017-10-10
  • 探索PowerShell(十二) 篩選器 Filters

    探索PowerShell(十二) 篩選器 Filters

    篩選器是函數(shù)的一種特殊形式
    2012-12-12
  • Powershell腳本中包含文件資源的例子

    Powershell腳本中包含文件資源的例子

    這篇文章主要介紹了Powershell腳本中包含文件資源的例子,本文直接給出示例代碼,本文腳本代碼適應(yīng)Powershell3.0及以后版本,需要的朋友可以參考下
    2015-03-03

最新評(píng)論

沁源县| 宣武区| 兴宁市| 保靖县| 太原市| 嘉峪关市| 上犹县| 淮北市| 新平| 拉萨市| 边坝县| 齐河县| 常熟市| 蓬溪县| 柘荣县| 墨脱县| 余干县| 云梦县| 绥阳县| 二连浩特市| 敦化市| 阳西县| 民乐县| 文安县| 南康市| 青神县| 洛隆县| 呈贡县| 香格里拉县| 凤凰县| 临清市| 乌审旗| 朝阳市| 松阳县| 和林格尔县| 绥中县| 敦煌市| 许昌市| 怀远县| 海淀区| 南澳县|