Power shell
Upcoming SlideShare
Loading in...5
×
 

Power shell

on

  • 214 views

 

Statistics

Views

Total Views
214
Views on SlideShare
214
Embed Views
0

Actions

Likes
0
Downloads
1
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
  • http://technet.microsoft.com/en-us/library/hh849944.aspx

Power shell Power shell Presentation Transcript

  • Powershell JASON
  • Powershell  Function  ScriptBlock  New-Object  Format-Table  Convert-Html
  • 輸入某數,算出該數階乘(Factorial)  Function ?  ScriptBlock ? View slide
  • ScriptBlock  $block = { Write-Host “Hello ScriptBlock” }  Execute  &$block View slide
  • 取得目前近 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 | Add-Member -type NoteProperty -name Name -Value $p.ProcessName $info | Add-Member -type NoteProperty -name Pid -Value $p.Id } $list += $info $list
  • 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
  • Example3 $process = Get-Process | select -First 10 $list = $process | select @{Name=“Name”;Expression= { $_.ProcessName} }, @{Name=“Pid”; Expression= { $_.Id } } $list
  • 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-date) -post (get-date)