PowerShell Shortcuts
5 categories · 29 shortcuts
01
Cmdlet
6 shortcuts- 显示 cmdlet 帮助Get-Help
- 列出所有命令Get-Command
- 列出项目(ls)Get-ChildItem
- 更改目录(cd)Set-Location
- 复制项目(cp)Copy-Item
- 删除项目(rm)Remove-Item
02
管道
6 shortcuts- 将输出管道传递到下一条命令|
- 选择属性|Select-Object
- 筛选对象|Where-Object
- 排序对象|Sort-Object
- 遍历对象|ForEach-Object
- 导出到 CSV|Export-Csv
03
变量
6 shortcuts- 赋值变量$var=value
- 访问环境变量$env:PATH
- 当前管道对象$_
- 当前管道对象(别名)$PSItem
- 列出所有变量Get-Variable
- 删除变量Remove-Variable
04
函数
5 shortcuts- 定义函数functionName{}
- 声明参数param()
- 返回值return
- 列出函数Get-Command-CommandTypeFunction
- 删除函数Remove-ItemFunction:Name
05
远程
6 shortcuts- 启动交互式会话Enter-PSSession
- 结束会话Exit-PSSession
- 远程运行命令Invoke-Command
- 创建持久会话New-PSSession
- 列出会话Get-PSSession
- 关闭会话Remove-PSSession