Jason
Array
   > $a = 1, 2, 3, 4, 5

   String.Object[]

   > $b = 1, “C”, 2.99, (Get-Process)

   可用 @() ,表示新增 Array
Array
   > $a = 2, 3, 4

   > $a[0, 2]

   > $a[0, -1]

   > $a[1] = 10, 20, 30

   > $a = $a + 1
Array
   > 1, 2, 3, 4 –contains 4

   > 1, 2, 3,4 –notcontains 3

   > 1, 2, 3 –contains “3”

   > 1, 2, “03” –contains 3
ForEach-Object
簡寫為 foreach

> 1,2,3 | ForEach-Object { $_ * 2 }
或
> 1,2,3 | foreach { $_ * 2 }
Select-Object
簡寫為 select

> Get-Process chrome | Select-Object ProcessName,Id
Sort-Object
簡寫為 sort

Get-Process chrome | Sort-Object Id

Get-Process chrome | Sort-Object Id -Descending
Tee-Object
簡寫為 tee
>3,2,1 | Tee-Object -Variable unsorted | Sort-Object
1
2
3

>$unsorted
3
2
1
Group-Object
簡寫為 group

> dir | Group-Object -Property Extension

Count Name                 Group
----- ----                -----
   1 .android          {.android}
   1 .10               {.gstreamer-0.10}
  16                   {Contacts, Desktop, Documents, Downloads...}
   1 .kdiff3rc         {.kdiff3rc}
   1 .userId           {.org.eclipse.epp.usagedata.recording.userId}
   1 .txt              {a.txt}
   1 .ini              {mercurial.ini}
Measure-Object

>1,2,3,4 | Measure-Object -Sum -Max -Min -Average

Count : 4
Average : 2.5
Sum    : 10
Maximum : 4
Minimum : 1
Compare-Object
簡寫為 diff
>$a = @(1,2,4)
>$b = @(1,3,4)
>Compare-Object -ReferenceObject $a -DifferenceObject $b
>Compare-Object $a $b

InputObject SideIndicator
    ----------- -------------
             3 =>
             2 <=
Read Word File
ProgID : Word.Application

$wordApp = New-Object -COM Word.Application
$file = (dir Test.docx).FullName
$doc = $wordApp.Documents.Open($file)
$text = $doc.Content.Text
$text

$wordApp.Exit
Create Word File
$path = Join-Path (Get-Location) create.doc
$wordApp = New-Object -COM Word.Application
#$wordApp.Visible = $true
if (Test-Path $path)
{
    del $path
}

$doc = $wordApp.Documents.Add()
$doc.Content.Text = "This is a book!!"
$doc.SaveAs($path)

$wordApp.Quit()
Edit Word File
$wordApp = New-Object -COM Word.Application
$file = (dir Test.docx).FullName
$doc = $wordApp.Documents.Open($file)
$documentFront = $doc.Content
$documentFront.End = $start.Start

$documentFront.Text ="Sorry"
$documentFront.Font.Name="Times new roman"
$documentFront.Font.ColorIndex = 6

$doc.save()
$wordApp.Quit()
Reference
http://technet.microsoft.com/zh-TW/library/dd315334.aspx

http://www.books.com.tw/exep/prod/booksfile.php?item=00104


 http://powershell.com/cs/blogs/ebook/default.aspx

Power shell object