国产宅男网站在线|亚洲A级性爱免费视频|亚洲中精品级在线|午夜福利AA毛

  • <dd id="gf5jf"><th id="gf5jf"></th></dd>

    <cite id="gf5jf"><label id="gf5jf"></label></cite>
  • <div id="gf5jf"><listing id="gf5jf"></listing></div>
    學習啦 > 學習電腦 > 操作系統(tǒng) > Linux教程 > PowerShell命令的基本知識

    PowerShell命令的基本知識

    時間: 志藝942 分享

    PowerShell命令的基本知識

      你知道PowerShell命令的基本知識 么?PowerShell的命令叫做cmdlet,接下來是小編為大家收集的PowerShell命令的基本知識,希望能幫到大家。

      PowerShell命令的基本知識

      •PowerShell的命令叫做cmdlet

      •具有一致的命名規(guī)范,都采用動詞-名詞形式,如New-Item

      •動詞部分一般為Add、New、Get、Remove、Set等

      •命令的別名一般兼容Windows Command以及Linux Shell,如Get-ChildItem命令使用dir或ls均可

      •PowerShell 命令產生的結果都是DLR對象

      •PowerShell命令不區(qū)分大小寫

      以文件操作為例講解PowerShell命令的基本用法

      •新建目錄 New-Item b2 -ItemType Directory

      •新建文件 New-Item a.txt -ItemType File

      •刪除目錄 Remove-Item b2

      •遞歸列pre開頭的文件或目錄,只列出名稱 Get-ChildItem -Recurse -Name -Filter "pre*“

      •顯示文本內容 Get-Content a.txt

      •設置文本內容 Set-Content a.txt -Value "content1“

      •追加內容 Add-Content a.txt -Value “content2“

      •清除內容 Clear-Content a.txt

      使用幫助

      •使用CHM查看幫助:在任務欄PowerShell圖標上點右鍵即可

      •Get-Help命令(man/help),默認為精簡,如果要查看全幫助,可使用 –Full 參數(shù)

      •例:查找關于Content的幫助 Get-Help Content

      獲取cmdlet命令

      •使用Get-Command(gcm)

      •獲取Connent相關命令 gcm *Content*

      別名(Alias)

      •顯示所有命令的別名gal(Get-Alias)

      •新建別名 New-Alias tt Get-ChildItem

      •設置別名Set-Alias ls1 Get-ChildItem

      •導出別名列表 Export-Alias -Path alias.txt

      •導入別名列表 Import-Alias -Path alias.txt

      格式化輸出

      •Format-Wide eg: ls | Format-Wide

      •Format-List :以Key:Value形式展現(xiàn)

      •Format-Table:以列表展現(xiàn)

      •Format-Custom:以對象的層次關系展現(xiàn)

      管道處理

      •循環(huán)處理 ls -Name | foreach {$_+"dsf"}

      •篩選 ls | where {$_ -match “admin”}

      •排序 ls | Sort-Object -Descending -Property length -Unique

      •選擇 ls | Select-Object -Skip 10 -First 10

      
    看了“PowerShell命令的基本知識”還想看:

    1.win10怎么快速打開命令行工具cmd

    2.DOS操作系統(tǒng)下運行命令合集

    3.怎樣在cmd和powershell中使用git命令

    4.Win10怎么用命令重新安裝內置應用

    5.Win10系統(tǒng)如何使用命令卸載自帶應用

    2892719