Powershell學習筆記:(二)、基礎知識

從Window7之後,WIndows系統都自帶了Windows PowerShell。shell

自帶版本以下spa

WIndow7  2.0
WIndow8   3.0
Window8.1      4.0
Window10    5.0/5.1

 

 

在Window10系統中,使用PowerShell代替了CMD做爲默認的命令環境code

 

如何查看PowerShell版本?blog

1  $PSVersionTable

運行結果以下:get

關於PowerShell中的命令命名cmd

powershell中命令的命名使用的是動-名詞結構it

io

Get-Datetable

Get-Aliasclass

和CMD通用的命令

powershell中有許多命令是和cmd中的命令通用的

 

cat dir mount rm
cd echo move rmdir
chdir erase popd sleep
clear h ps sort
cls history pushd tee
copy kill pwd type
del lp r write
diff ls ren

以上命令在Powershell中實際上是以alias(別名)的形式存在的

如dir其實是Get-ChildItem的別名。

執行

Get-Alias dir

能夠看到

要查看Powershell自帶的所有別名,執行不帶參數的Get-Alias命令。

建立別名

使用Set-Alias命令能夠建立別名

如:使用Set-Alias命令將Get-Content命令的別名設置爲open

1 Set-Alias -Name open -Value Get-Content
2 open  "D:\test.txt"

 Powershell中的命令是不區分大小寫的

get-dateGet-Date是同樣的,不過仍是建議首字母大寫

相關文章
相關標籤/搜索