PowerShell 經常使用命令

查看 PowerShell 版本python

get-host

或

$host.version

或

$PSVersionTable.PSVERSION

命令執行狀況shell

新建目錄rest

New-Item test -type Directory

命令執行狀況blog

新建文件get

New-Item test.txt -type File

命令執行狀況io

-type 指定建立的是文件仍是目錄class

刪除目錄或文件test

Remove-Item 文件或目錄

命令執行結果下載

顯示文本內容im

get-content 1.txt

命令執行結果

設置文本的內容

set-content 1.txt -value "hello"

命令執行結果

追加文本內容

add-content 1.txt -value "world"

命令執行結果

查看 PowerShell 的執行策略

Get-ExecutionPolicy

命令執行結果

Restricted 爲腳本不能運行,是默認設置

Unrestricted 爲容許全部的腳本運行

RemoteSigned 爲只能運行本地建立的腳本,不能運行從網上下載的腳本,除了有數字簽名證書

Allsigned 爲只運行有受信任的發佈者簽名的腳本

設置 Powershell 的執行策略

Set-ExecutionPolicy Unrestricted

命令執行結果

相關文章
相關標籤/搜索