亚洲欧美精品沙发,日韩在线精品视频,亚洲Av每日更新在线观看,亚洲国产另类一区在线5

<pre id="hdphd"></pre>

  • <div id="hdphd"><small id="hdphd"></small></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 命令產(chǎn)生的結(jié)果都是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*“

        •顯示文本內(nèi)容 Get-Content a.txt

        •設(shè)置文本內(nèi)容 Set-Content a.txt -Value "content1“

        •追加內(nèi)容 Add-Content a.txt -Value “content2“

        •清除內(nèi)容 Clear-Content a.txt

        使用幫助

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

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

        •例:查找關(guān)于Content的幫助 Get-Help Content

        獲取cmdlet命令

        •使用Get-Command(gcm)

        •獲取Connent相關(guān)命令 gcm *Content*

        別名(Alias)

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

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

        •設(shè)置別名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:以對象的層次關(guān)系展現(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怎么用命令重新安裝內(nèi)置應(yīng)用

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

      2892719