好湿?好紧?好多水好爽自慰,久久久噜久噜久久综合,成人做爰A片免费看黄冈,机机对机机30分钟无遮挡

主頁 > 知識庫 > Windows Powershell過濾管道結果

Windows Powershell過濾管道結果

熱門標簽:如何根據經緯度百度地圖標注 六寸地圖標注點怎么刪除 新鄭電銷機器人一個月多少錢 地圖標注的圖案 騰訊地圖標注中心怎么標注 萬全縣地圖標注app 莫拉克電梯系統外呼怎么設置 印臺區呼叫中心外呼系統 電話機器人公司招聘

如果要過濾對象可以使用Where-Object;如果要過濾對象的屬性,可以使用Select-Object;如果要自定義個性化的過濾效果可以使用ForEach-Object。最后如果想過濾重復的結果,可是使用Get-Uinque。

篩選管道結果中的對象

如果你只對管道結果的特定對象感興趣,可是使用Where-Object對每個結果進行嚴格篩選,一旦滿足你的標準才會保留,不滿足標準的就會自動丟棄。例如你通過Get-service查看運行在機器上的當前服務,但是可能只關心哪些正在運行的服務,這時就可是通過每個服務的屬性Status進行過濾。但是前提條件是你得事先知道待處理的對象擁有哪些屬性。你可以通過Format-List * ,也可以通過Get-memeber。

PS C:Powershell> Get-service | Select-Object -First 1 | Format-List *

Name        : AdobeARMservice
RequiredServices  : {}
CanPauseAndContinue : False
CanShutdown     : False
CanStop       : True
DisplayName     : Adobe Acrobat Update Service
DependentServices  : {}
MachineName     : .
ServiceName     : AdobeARMservice
ServicesDependedOn : {}
ServiceHandle    :
Status       : Running
ServiceType     : Win32OwnProcess
Site        :
Container      :

PS C:Powershell> Get-service | Select-Object -First 1 | Get-Member -MemberType
Property

  TypeName: System.ServiceProcess.ServiceController

Name        MemberType Definition
----        ---------- ----------
CanPauseAndContinue Property  System.Boolean CanPauseAndContinue {get;}
CanShutdown        Property  System.Boolean CanShutdown {get;}
CanStop            Property  System.Boolean CanStop {get;}
Container           Property  System.ComponentModel.IContainer Container {g...
DependentServices    Property  System.ServiceProcess.ServiceController[] Dep...
DisplayName        Property  System.String DisplayName {get;set;}
MachineName       Property  System.String MachineName {get;set;}
ServiceHandle        Property  System.Runtime.InteropServices.SafeHandle Ser...
ServiceName         Property  System.String ServiceName {get;set;}
ServicesDependedOn  Property  System.ServiceProcess.ServiceController[] Ser...
ServiceType          Property  System.ServiceProcess.ServiceType ServiceType...
Site                Property  System.ComponentModel.ISite Site {get;set;}
Status              Property  System.ServiceProcess.ServiceControllerStatus...

知道了對象有哪些屬性,要完成上面提到的需求就很容易了。

PS C:Powershell> get-service | Where-Object {$_.Status -eq "Running"}

Status  Name        DisplayName
------  ----        -----------
Running AdobeARMservice   Adobe Acrobat Update Service
Running AppHostSvc       Application Host Helper Service
Running AppIDSvc      Application Identity
Running Appinfo       Application Information
Running AudioEndpointBu...  Windows Audio Endpoint Builder
Running Audiosrv      Windows Audio
Running BDESVC       BitLocker Drive Encryption Service
Running BFE         Base Filtering Engine
Running BITS        Background Intelligent Transfer Ser...
Running CcmExec       SMS Agent Host

這里稍微解釋一下,Where-Object的參數的是一個布爾表達式,$_代表過濾過程中經過管道的當前結果。另外Where-Object還有一個別名 “?” 更形象。

選擇對象的屬性

包含在每一個對象中的屬性可能有很多,但是并不是所有的屬性你都感興趣,這時可以使用Select-Object 限制對象的屬性。接下來的例子演示如果獲取機器上匿名帳號的完整信息。

PS C:Usersv-bali.FAREAST> Get-WmiObject Win32_UserAccount -filter "LocalAccount=True AND Name='guest'"

AccountType : 512
Caption     : myhomeguest
Domain     : myhome
SID        : S-1-5-21-3064017030-3269374297-2491181182-501
FullName    :
Name    : guest

如果你只對用戶名、描述,啟用感興趣。

PS C:Powershell> Get-WmiObject Win32_UserAccount -filter "LocalAccount=True AND
 Name='guest'" | Select-Object Name,Description,Disabled

Name            Description                 Disabled
----              -----------                 --------
guest           Built-in account for gu...           True

Select-Object也支持通配符。

Dir | Select-Object * -exclude *A*
限制對象的數量

列出最后修改的5個文件

PS C:Powershell> Dir | Select-Object -ExcludeProperty "*N*" -First 5

  目錄: C:Powershell

Mode        LastWriteTime   Length Name
----        -------------   ------ ----
-a---    2011/11/24   18:30   67580 a.html
-a---    2011/11/24   20:04   26384 a.txt
-a---    2011/11/24   20:26   12060 alias
-a---    2011/11/25   11:20    556 employee.xml
-a---    2011/11/29   19:23   21466 function.ps1

列出占用CPU最大的5個進程

PS C:Powershell> get-process | sort -Descending cpu | select -First 5

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s)  Id ProcessName
------- ------ ----- ----- ----- ------  -- -----------
  1336   98 844304 809388 1081 164.69 3060 iexplore
  224   10 74676 62468  188 81.10 4460 AcroRd32
  130   9 28264 39092  167 70.57 3436 dwm
  169   8  7576 29568  134 65.22 3364 notepad
  989   34 72484 35996  393 62.67 4724 BingDict

逐個處理所有管道結果

如果想對管道結果進行逐個個性化處理可是使用ForEach-Object

ls | ForEach-Object {"文件名: 文件大小(M): " -f $_.Name,$_.Length/1M}
PS C:Powershell> ls | ForEach-Object {"文件名:{0} 文件大小{1}KB: " -f $_.Name,
($_.length/1kb).tostring()}
文件名:a.html 文件大小65.99609375KB:
文件名:a.txt 文件大小25.765625KB:
文件名:alias 文件大小11.77734375KB:
文件名:employee.xml 文件大小0.54296875KB:
文件名:function.ps1 文件大小20.962890625KB:
文件名:LogoTestConfig.xml 文件大小0.181640625KB:
文件名:ls.html 文件大小3.37890625KB:
刪除重復對象

Get-Unique可以從已排序的對象列表中刪除重復對象。Get-Unique會逐個遍歷對象,每次遍歷時都會與前一個對象進行比較,如果和前一個對象相等就會拋棄當前對象,否則就保留。所以如果對象列表中沒有排序,Get-Unique不能完全發揮作用,只能保證相鄰對象不重復。

PS C:Powershell> 1,2,1,2 | Get-Unique
1
2
1
2
PS C:Powershell> 1,2,1,2 | Sort-Object |Get-Unique
1
2
PS C:Powershell> ls | foreach{$_.extension} | Sort-Object |Get-Unique

.bat
.html
.ps1
.txt
.vbs
.xml

您可能感興趣的文章:
  • Shell腳本中管道的幾種使用實例講解
  • Shell腳步攻略之管道重定向基礎
  • PowerShell管道入門必看篇(管道例子大全)
  • linux shell 管道命令(pipe)使用及與shell重定向區別
  • PowerShell實現按條件終止管道的方法
  • PowerShell中終止管道的方法
  • PowerShell入門教程之PowerShell管道介紹
  • Windows Powershell導出管道結果
  • shell腳本一鍵同時推送代碼至github和gitee的解決辦法
  • 如何利用 tee 命令調試shell腳本中的管道

標簽:汕頭 臨汾 疫苗接種 天水 湘潭 南昌 喀什 襄陽

巨人網絡通訊聲明:本文標題《Windows Powershell過濾管道結果》,本文關鍵詞  Windows,Powershell,過濾,管道,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《Windows Powershell過濾管道結果》相關的同類信息!
  • 本頁收集關于Windows Powershell過濾管道結果的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 别揉我胸?啊?嗯~接吻| 边做饭边被躁我和邻居的小| 亚洲综合日韩精品欧美综合区 | 美女喷液视频| 美女被狂揉下部?羞羞作文| 无码人妻av久久久一区二区三区| 将舌头伸入她两腿间的花缝里h| 老板好大好爽我要喷水了| 中国一级漂亮航空美女毛片| 人人爽日日躁夜夜躁A片小说免费 天天槽夜夜槽躁躁2021 | 国产女主播户外勾搭路人| 星辰电影| 国产成人无码免费看片色哟哟| 视频aavvmm国产野外| 宅福利 蜜桃社| 白嫩美女亚洲日韩在线| a级毛片毛片免费观看永久| 95视频在线观看哔哩哔哩| 《爆乳女教师》HD在线| www.天天操.com| 在线观看黄p免费| 一女二男3p啪啪图动图| 国产91?在线播放九色潘多| 99久久er热在这里都是精品99 | 揉搓着饱满圆润的双乳| 精品成人无码亚洲AV| 超清91丝袜在线| 欧美怡红院免费全部视频| 性-乱-做-爱视频| 黄色小爽文| HD欧美free性XXX护士| 鲁鲁在线观看| 娇妻之欲海| 美国一级大黄一片免费中文| 久久人人爽人人片av人成| 调教play小说| 亚洲AV一区二区大桥未久 | 东京热无码A片免费播放| 欧美aa级| 91在线视频免费播放| 越南电影《性的暴行》|