PowerShell 相关命令

安装 pwsh

升级 PowerShell

winget 方式

1
2
winget search Microsoft.PowerShell
winget install --id Microsoft.PowerShell --source winget

Iex 方式

1
iex "& { $(irm https://aka.ms/install-powershell.ps1) } -UseMSI"

查看当前 PowerShell 版本

1
Get-Host | Select-Object Version

删除匹配后缀的文件

1
Remove-Item * -Include *.meta -Recurs

打开当前文件夹

1
ii .

压缩/解压缩

将文件或文件夹 test 压缩为 test .zip

1
Compress-Archive -Path D:\test -DestinationPath E:\test.zip

将文件 test .zip 解压到 test 目录下

1
Expand-Archive -Path E:\test.Zip -DestinationPath F:\test