0
Powershell
JASON
Powershell


Function



ScriptBlock



New-Object



Format-Table



Convert-Html
輸入某數,算出該數階乘(Factorial)


Function ?



ScriptBlock ?
ScriptBlock


$block = { Write-Host “Hello ScriptBlock” }



Execute


&$block
取得目前近 5 分鐘內的 Process info


Get-Process | Get-RecentlyStarted


利用 begin、process、end



利用 filter function
Filter Function
function Get-FileSize
{
begin
{
……
}
process
{
…..
}
end
{
….
}
}
dir *.txt | Get-FileSize
Example1
$process = Get-Process | select -First 10
$list = @()
foreach($p in $process)
{
$info = New-Object PSObject
$info...
Example2
$process = Get-Process | select -First 10
$list = @()
foreach($p in $process)
{
$info = New-Object PSObject -Prop...
Example3

$process = Get-Process | select -First 10
$list = $process | select @{Name=“Name”;Expression= { $_.ProcessName} ...
Format-Table (ft)

$list | Format-Table -AutoSize
Format-List (fl)
$list | Format-List

$list | Format-List -GroupBy Name
ConvertTo-Html (cth)
$list | ConvertTo-HTML -cssuri "Layout.css"
-title "Process"
-body "<H2>Process Info</H2>"
-pre (get-...
Power shell
Upcoming SlideShare
Loading in...5
×

Power shell

195

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
195
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • http://technet.microsoft.com/en-us/library/hh849944.aspx
  • Transcript of "Power shell"

    1. 1. Powershell JASON
    2. 2. Powershell  Function  ScriptBlock  New-Object  Format-Table  Convert-Html
    3. 3. 輸入某數,算出該數階乘(Factorial)  Function ?  ScriptBlock ?
    4. 4. ScriptBlock  $block = { Write-Host “Hello ScriptBlock” }  Execute  &$block
    5. 5. 取得目前近 5 分鐘內的 Process info  Get-Process | Get-RecentlyStarted  利用 begin、process、end  利用 filter function
    6. 6. Filter Function function Get-FileSize { begin { …… } process { ….. } end { …. } } dir *.txt | Get-FileSize
    7. 7. Example1 $process = Get-Process | select -First 10 $list = @() foreach($p in $process) { $info = New-Object PSObject $info | Add-Member -type NoteProperty -name Name -Value $p.ProcessName $info | Add-Member -type NoteProperty -name Pid -Value $p.Id } $list += $info $list
    8. 8. Example2 $process = Get-Process | select -First 10 $list = @() foreach($p in $process) { $info = New-Object PSObject -Property @{ Name = $p.ProcessName; Pid = $p.Id } $list += $info } $list
    9. 9. Example3 $process = Get-Process | select -First 10 $list = $process | select @{Name=“Name”;Expression= { $_.ProcessName} }, @{Name=“Pid”; Expression= { $_.Id } } $list
    10. 10. Format-Table (ft) $list | Format-Table -AutoSize
    11. 11. Format-List (fl) $list | Format-List $list | Format-List -GroupBy Name
    12. 12. ConvertTo-Html (cth) $list | ConvertTo-HTML -cssuri "Layout.css" -title "Process" -body "<H2>Process Info</H2>" -pre (get-date) -post (get-date)
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×