从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-date和Get-Date是同样的,不过仍是建议首字母大写