PowerShell 笔记

PowerShell 笔记

1.运行环境

Windows (x86/x64/arm64) / macOS / Linux

截至 2025-03-20 最新版本:7.5.0 (2025-01-24 发布)

2.安装运行

Windows 版本升级

Windows系统通常已集成PowerShell,后续想要新版本则需进行升级。

Tips:PowerShell v5和v7安装目录有所不同、可以并存。

下载PowerShell v7 ZIP包【点击直达】,解压到$env:ProgramFiles\PowerShell\7下:

image-20250320155015685

将PowerShell v7添加到PATH环境变量中:

image-20250320160128565

添加环境变量后可通过pwsh运行:

image-20250320160357211

更多说明详见官方文档 Migrating from Windows PowerShell 5.1 to PowerShell 7点击直达

3.一些命令

  • 查看当前版本
1
$PSVersionTable.PSVersion

image-20250320141457066

  • 显示模块路径
1
$Env:PSModulePath -split (';')

image-20250320141506335

  • 显示profile路径
1
$PROFILE | Select-Object *Host* | Format-List

image-20250320141739545

参考资料