PowerShell书籍收藏

1、PowerShell两本电子书籍

2、Professional Windows powershell Programming

image

http://www.bonashen.com/wp-content/uploads/2010/09/ProfessionalWindowsPowerShellProgramming.pdf

3、Windows powershell Cookbook,2nd

image

http://www.bonashen.com/wp-content/uploads/2010/09/Windows_PowerShell_Cookbook,2nd.pdf

4、Effective Windows powershell

image

http://www.bonashen.com/wp-content/uploads/2010/09/EffectiveWindowsPowerShell.pdf

PowerShell两本电子书籍

powershell刚开始学,先前网购了一本电子工业出版社出版的《Windows powershell 2.0 应用编程最佳实践》。

后来在网上找到两本powershell电子书

1.Windows PowerShell Cookbook™

image

http://www.bonashen.com/wp-content/uploads/2010/09/OReilly.Windows.PowerShell.Cookbook.Oct.2007.pdf

2.Windows PowerShell in Action

image

http://www.bonashen.com/wp-content/uploads/2010/09/Manning.Windows.PowerShell.in.Action.Feb.2007.pdf

PowerShell 文件目录监视片段

摘自《Windows PowerShell 2.0应用编程最佳实践》

#pseventing 1.1
#filesystemwatcher
Add-PSSnapin pseventing 

$fsw = New-Object system.IO.FileSystemWatcher
$fsw.Path = [IO.Path]::GetTempPath()
$fsw.EnableRaisingEvents = $true 

Start-KeyHandler -CaptureCtrlC 

Connect-Event fsw changed,deleted -Verbose 

"watching $($fsw.path)"
"entering loop ... ctrl+C to exit"
$done = $false
while($events = @(Read-Event -Wait)){
   #read-event alays returns a cllection
   foreach($event in $events){
      switch($event.name){
          "ctrlc"{
            "cancelling..."
            $done = $true
            }
        "changed"{
            $event
            #$done = $true
        }
        "deleted"{
            $event
        }
      }
    }
    if($done -eq $true){
        break
    }
}    
调试结果如下图:
image