Power shell – scriptblock
Upcoming SlideShare
Loading in...5
×
 

Power shell – scriptblock

on

  • 295 views

 

Statistics

Views

Total Views
295
Views on SlideShare
295
Embed Views
0

Actions

Likes
0
Downloads
0
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Power shell – scriptblock Power shell – scriptblock Presentation Transcript

    • PowerShell – ScriptBlock Howard 2013/11/29
    • Script Block  用 { …… } 定義 Script Block  將 Script Block 指派給某一變數   $variable = { …… } 透過變數執行 Script Block - &  &$variable
    • Script Block
    • Script Block - 返回值 
    • Script Block - 返回值  回傳值後,後續的 script 仍會繼續執行  故 $result = 5
    • Script Block - 返回值 return  使用 return 以結束執行 script block
    • Script Block - 返回值 array 
    • Script Block – 參數 $args  預設變數 $args,用來取得呼叫 script block 時的參數
    • Script Block – 參數 param(param1, param2……)  按順序指定參數  缺點:要依參數順序給值  指定參數名稱後給值  指定參數名稱,可以縮寫  名稱需要足夠的長度,才能 視別不同的參數
    • Script Block – 參數 param – 型別定義、預設值、強制參數 
    • Script Block - Pipe  begin   在 pipe 執行之前會進入此 block process    Pipe 的每個 element 都會進此 block $_ 指的是當前物件 end  在 pipe 執行之前會進入此 block
    • Script Block - Pipe
    • Script Block - Pipe
    • Reference