PowerShell 技能连载 - Q1 技术回顾与展望

适用于 PowerShell 5.1 及以上版本

2026 年第一季度即将画上句号。回顾这三个月,PowerShell 生态在多个方向上都有值得关注的进展:PowerShell 7.x 持续迭代,跨平台能力进一步增强;AI 辅助编程工具链加速成熟,越来越多团队开始将大语言模型嵌入到自动化工作流中;社区在安全基线、基础设施即代码(IaC)等领域的最佳实践也在不断沉淀。

每个季度末做一次技术盘点,不仅是对过往工作的梳理,更是为下个阶段的学习和工作明确方向。本文将分三个部分展开:Q1 技术盘点、实战经验总结以及 Q2 学习路线规划,并附上可直接运行的 PowerShell 脚本来帮助你完成自己的回顾与展望。

Q1 技术盘点

第一个代码块帮助我们汇总本季度关注的核心技术动态,包括 PowerShell 版本更新、重要模块发布以及工具链改进。你可以基于这个模板定制自己的盘点清单。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# Q1 技术盘点脚本
$quarter = "2026-Q1"

# 当前 PowerShell 环境信息
$psInfo = [PSCustomObject]@{
Version = $PSVersionTable.PSVersion.ToString()
Edition = $PSVersionTable.PSEdition
OS = $PSVersionTable.OS
Machine = $PSVersionTable.Platform
}
Write-Host "=== 当前 PowerShell 环境 ===" -ForegroundColor Cyan
$psInfo | Format-List

# Q1 重点更新盘点
$updates = @(
[PSCustomObject]@{
Category = "PowerShell 核心"
Item = "PowerShell 7.5 LTS 持续维护,7.6 Preview 发布"
Impact = "性能优化,新增 ConvertFrom-Json -AsHashtable 改进"
}
[PSCustomObject]@{
Category = "AI 集成"
Item = "PowerShell AI 模块(PSAI)进入稳定版"
Impact = "可直接在脚本中调用本地/云端 LLM 完成文本处理"
}
[PSCustomObject]@{
Category = "安全模块"
Item = "Microsoft.PowerShell.SecretManagement 2.0"
Impact = "支持更多密钥保管库后端,跨平台凭据管理更便捷"
}
[PSCustomObject]@{
Category = "DSC v3"
Item = "Desired State Configuration v3 预览版更新"
Impact = "基于声明式配置,与容器化部署深度整合"
}
[PSCustomObject]@{
Category = "工具链"
Item = "PSScriptAnalyzer 1.23 规则扩展"
Impact = "新增 AI 相关脚本的安全审查规则"
}
[PSCustomObject]@{
Category = "社区"
Item = "PowerShell Gallery 月下载量突破 5 亿"
Impact = "生态持续增长,模块质量评估机制上线"
}
)

Write-Host "`n=== $quarter 技术盘点 ===" -ForegroundColor Cyan
$updates | Format-Table -AutoSize

# 统计已安装模块的更新情况
$installedModules = Get-InstalledModule |
Sort-Object Name -Unique |
Select-Object -First 10 Name, Version, RepositoryDescription

Write-Host "`n=== 已安装模块(前 10 个)===" -ForegroundColor Cyan
$installedModules | Format-Table -AutoSize

执行结果示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
=== 当前 PowerShell 环境 ===

Version : 7.5.0
Edition : Core
OS : Darwin 25.4.0 Darwin Kernel Version 25.4.0
Machine : Unix

=== 2026-Q1 技术盘点 ===

Category Item Impact
-------- ---- ------
PowerShell 核心 PowerShell 7.5 LTS 持续维护,7.6 Preview 发布 性能优化,新增 ConvertFrom-Json -AsHashtable 改进
AI 集成 PowerShell AI 模块(PSAI)进入稳定版 可直接在脚本中调用本地/云端 LLM 完成文本处理
安全模块 Microsoft.PowerShell.SecretManagement 2.0 支持更多密钥保管库后端,跨平台凭据管理更便捷
DSC v3 Desired State Configuration v3 预览版更新 基于声明式配置,与容器化部署深度整合
工具链 PSScriptAnalyzer 1.23 规则扩展 新增 AI 相关脚本的安全审查规则
社区 PowerShell Gallery 月下载量突破 5 亿 生态持续增长,模块质量评估机制上线

=== 已安装模块(前 10 个)===

Name Version RepositoryDescription
---- ------- ---------------------
Microsoft.PowerShell.SecretManagement 2.0.0 ...
PSScriptAnalyzer 1.23.0 ...
PSReadLine 2.4.2 ...

实战经验总结

Q1 中涌现了大量优秀的自动化模式和问题解决方案。以下脚本梳理了社区中最受关注的实践模式,并提供了可以直接用于项目模板的代码片段。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# Q1 实战经验总结脚本
Write-Host "=== Q1 实战经验总结 ===" -ForegroundColor Cyan

# 模式 1:结构化日志与错误处理
$patterns = @(
[PSCustomObject]@{
Pattern = "结构化日志(Structured Logging)"
Description = "使用 ConvertTo-Json 输出结构化日志,便于 ELK/Splunk 采集"
Popularity = "High"
}
[PSCustomObject]@{
Pattern = "并行任务(ForEach-Object -Parallel)"
Description = "利用 runspace 池并发执行,显著缩短批量操作耗时"
Popularity = "High"
}
[PSCustomObject]@{
Pattern = "AI 辅助脚本生成"
Description = "通过 PSAI 模块调用 LLM 自动生成样板代码并人工审核"
Popularity = "Medium-High"
}
[PSCustomObject]@{
Pattern = "凭据安全传递链"
Description = "SecretManagement + Key Vault 统一管理敏感信息"
Popularity = "Medium"
}
[PSCustomObject]@{
Pattern = "跨平台环境检测"
Description = "用 $IsWindows/$IsLinux/$IsMacOS 编写通用脚本"
Popularity = "Medium"
}
)

$patterns | Format-Table -AutoSize

# 实用函数:检测脚本是否通过 lint 检查
function Test-ScriptQuality {
param(
[Parameter(Mandatory)]
[string]$ScriptPath
)

$issues = @()

# 检查文件是否存在
if (-not (Test-Path $ScriptPath)) {
$issues += "文件不存在: $ScriptPath"
return $issues
}

$content = Get-Content $ScriptPath -Raw

# 基础质量检查
if ($content.Length -lt 50) {
$issues += "脚本内容过短,可能缺少有效逻辑"
}

if ($content -notmatch 'try\s*\{') {
$issues += "未发现 try/catch 错误处理"
}

if ($content -notmatch '\[CmdletBinding\(\)') {
$issues += "建议添加 CmdletBinding() 以支持高级函数特性"
}

if ($content -notmatch '#\s*(Synopsis|Description)') {
$issues += "建议添加基于注释的帮助文档"
}

if ($content -match '\-Password\s+\$') {
$issues += "检测到明文密码参数,建议使用 SecureString 或 SecretManagement"
}

if ($issues.Count -eq 0) {
Write-Host " [PASS] $ScriptPath 质量检查通过" -ForegroundColor Green
} else {
Write-Host " [WARN] $ScriptPath 发现 $($issues.Count) 个建议" -ForegroundColor Yellow
$issues | ForEach-Object { Write-Host " - $_" -ForegroundColor DarkYellow }
}

return $issues
}

# 批量检查脚本质量示例
Write-Host "`n--- 脚本质量检查示例 ---" -ForegroundColor Green
$sampleScripts = Get-ChildItem -Path "." -Filter "*.ps1" -Recurse -ErrorAction SilentlyContinue |
Select-Object -First 5

foreach ($script in $sampleScripts) {
Test-ScriptQuality -ScriptPath $script.FullName | Out-Null
}

执行结果示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
=== Q1 实战经验总结 ===

Pattern Description Popularity
------- ----------- ----------
结构化日志(Structured Logging) 使用 ConvertTo-Json 输出结构化日志,便于 ELK/Splunk 采集 High
并行任务(ForEach-Object -Parallel)利用 runspace 池并发执行,显著缩短批量操作耗时 High
AI 辅助脚本生成 通过 PSAI 模块调用 LLM 自动生成样板代码并人工审核 Medium-High
凭据安全传递链 SecretManagement + Key Vault 统一管理敏感信息 Medium
跨平台环境检测 用 $IsWindows/$IsLinux/$IsMacOS 编写通用脚本 Medium

--- 脚本质量检查示例 ---
[PASS] ./deploy.ps1 质量检查通过
[WARN] ./backup.ps1 发现 2 个建议
- 未发现 try/catch 错误处理
- 建议添加 CmdletBinding() 以支持高级函数特性
[PASS] ./monitor.ps1 质量检查通过

Q2 学习路线

展望第二季度,以下脚本帮你规划学习路线、追踪技术趋势以及关注社区活动。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# Q2 学习路线规划脚本
Write-Host "=== 2026 Q2 学习路线 ===" -ForegroundColor Cyan

# Q2 重点学习方向
$learningPath = @(
[PSCustomObject]@{
Priority = "P0 - 必学"
Topic = "PowerShell 7.6 新特性与迁移指南"
Resources = "官方 CHANGELOG、PowerShell Blog、GitHub Releases"
Timeline = "4 月"
}
[PSCustomObject]@{
Priority = "P0 - 必学"
Topic = "AI Agent 自动化工作流深度实践"
Resources = "PSAI 模块文档、LangChain-PowerShell 集成案例"
Timeline = "4-5 月"
}
[PSCustomObject]@{
Priority = "P1 - 推荐"
Topic = "容器化 PowerShell 脚本(Docker/Podman)"
Resources = "Microsoft 官方 Docker 镜像、DSC v3 文档"
Timeline = "5 月"
}
[PSCustomObject]@{
Priority = "P1 - 推荐"
Topic = "结构化配置管理(YAML/JSON Schema 验证)"
Resources = "powershell-yaml 模块、Pester 6 测试框架"
Timeline = "5-6 月"
}
[PSCustomObject]@{
Priority = "P2 - 关注"
Topic = "WebAssembly 上的 PowerShell 实验性支持"
Resources = "PowerShell Community Calls、实验性特性 RFC"
Timeline = "6 月"
}
[PSCustomObject]@{
Priority = "P2 - 关注"
Topic = "安全供应链:模块签名与 SBOM 生成"
Resources = "PowerShell Gallery 安全指南、NuGet 签名工具"
Timeline = "6 月"
}
)

$learningPath | Format-Table -AutoSize

# Q2 社区活动日历
$events = @(
[PSCustomObject]@{
Date = "2026-04-15"
Event = "PowerShell Community Call(每月第三个周三)"
Type = "线上"
}
[PSCustomObject]@{
Date = "2026-05-06"
Event = "PowerShell + AI Summit 虚拟大会"
Type = "线上"
}
[PSCustomObject]@{
Date = "2026-05-20"
Event = "PowerShell Community Call"
Type = "线上"
}
[PSCustomObject]@{
Date = "2026-06-17"
Event = "PowerShell Community Call"
Type = "线上"
}
[PSCustomObject]@{
Date = "2026-06-23"
Event = "PSConfEU 2026(欧洲 PowerShell 大会)"
Type = "线下/线上"
}
)

Write-Host "`n=== Q2 社区活动 ===" -ForegroundColor Cyan
$events | Format-Table -AutoSize

# 生成个人学习进度追踪文件
$progressFile = "Q2-Learning-Progress-$(Get-Date -Format 'yyyyMMdd').json"
$progress = [PSCustomObject]@{
GeneratedDate = (Get-Date -Format "yyyy-MM-dd")
Quarter = "2026-Q2"
Goals = $learningPath | Select-Object Topic, Timeline
Events = $events
Status = "NotStarted"
}

$progress | ConvertTo-Json -Depth 3 | Set-Content $progressFile
Write-Host "`n学习进度追踪文件已生成: $progressFile" -ForegroundColor Green

执行结果示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
=== 2026 Q2 学习路线 ===

Priority Topic Resources Timeline
-------- ----- --------- --------
P0 - 必学 PowerShell 7.6 新特性与迁移指南 官方 CHANGELOG、PowerShell Blog、GitHub Releases 4 月
P0 - 必学 AI Agent 自动化工作流深度实践 PSAI 模块文档、LangChain-PowerShell 集成案例 4-5 月
P1 - 推荐 容器化 PowerShell 脚本(Docker/Podman) Microsoft 官方 Docker 镜像、DSC v3 文档 5 月
P1 - 推荐 结构化配置管理(YAML/JSON Schema 验证) powershell-yaml 模块、Pester 6 测试框架 5-6 月
P2 - 关注 WebAssembly 上的 PowerShell 实验性支持 PowerShell Community Calls、实验性特性 RFC 6 月
P2 - 关注 安全供应链:模块签名与 SBOM 生成 PowerShell Gallery 安全指南、NuGet 签名工具 6 月

=== Q2 社区活动 ===

Date Event Type
---- ----- ----
2026-04-15 PowerShell Community Call(每月第三个周三) 线上
2026-05-06 PowerShell + AI Summit 虚拟大会 线上
2026-05-20 PowerShell Community Call 线上
2026-06-17 PowerShell Community Call 线上
2026-06-23 PSConfEU 2026(欧洲 PowerShell 大会) 线下/线上

学习进度追踪文件已生成: Q2-Learning-Progress-20260331.json

注意事项

  1. 季度复盘是持续学习的基础:建议每个季度末用 30 分钟运行一次盘点脚本,回顾自己的技术成长轨迹,比漫无目的地浏览技术文章更高效。

  2. AI 工具是加速器而非替代品:Q1 中 AI 辅助编程工具确实提升了效率,但生成的代码必须经过人工审核。建议将 PSScriptAnalyzer 作为 AI 生成代码的必经检查环节。

  3. 关注安全供应链:随着 PowerShell Gallery 生态壮大,模块安全性愈发重要。安装第三方模块前务必检查作者签名、下载量和社区评价,优先选择 Microsoft 官方或知名社区成员维护的模块。

  4. 并行执行的适用边界ForEach-Object -Parallel 虽然强大,但不适合涉及共享状态修改的场景。使用前要评估线程安全性,必要时用 ConcurrentDictionary 或文件锁来协调并发访问。

  5. 跨平台意识要从现在培养:即使当前只用 Windows,在编写新脚本时养成使用 $IsWindows/$IsLinux/$IsMacOS 做环境检测的习惯,这会让未来的迁移成本趋近于零。

  6. 参与社区是最好的学习方式:每月的 PowerShell Community Call 是了解官方路线图的最佳窗口,PSConfEU 和各类虚拟大会则能帮你拓宽视野。建议至少每季度参加一次社区活动,保持与生态前沿的同频。

PowerShell 技能连载 - 2025 年度回顾与 2026 展望

适用于 PowerShell 5.1 及以上版本

2025 年对 PowerShell 社区而言是里程碑式的一年。PowerShell 7.5 正式发布,全面拥抱 .NET 8 带来的性能提升与新 API,同时官方团队持续推动跨平台体验的统一。云原生、容器化和 GitOps 已经不再只是 buzzword,而是日常运维的基本范式,PowerShell 在其中扮演了越来越重要的胶水语言角色。

与此同时,AI 大模型的爆发深刻改变了自动化脚本的工作方式。从调用 OpenAI API 做日志分析,到用本地模型生成配置模板,再到 IDE 中的智能补全,AI 工具链已经深度融入 PowerShell 开发者的日常工作流。这一年我们见证了脚本编写方式从”查文档写代码”到”描述需求生成代码”的范式转变。

站在岁末年初的节点,本文将回顾 2025 年 PowerShell 生态的关键技术变化,梳理当前最实用的 AI 集成与云原生实战技巧,并展望 2026 年值得关注的趋势和学习方向。

2025 技术回顾

PowerShell 7.5 带来了一系列值得关注的新特性:改进了管道性能,增强了实验性特性中的 PSAdapter 模式,并且对 ConvertFrom-Json 等常用命令的输出做了优化。社区模块生态也蓬勃发展,Pester v6 正式发布,PSFramework 持续迭代。下面这段脚本盘点了一些关键模块的版本信息。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# 2025 年 PowerShell 生态关键信息盘点
$psInfo = @{
Version = $PSVersionTable.PSVersion.ToString()
Edition = $PSVersionTable.PSEdition
OS = $PSVersionTable.OS
Platform = $PSVersionTable.Platform
}

Write-Host "=== PowerShell 运行环境 ===" -ForegroundColor Cyan
$psInfo.GetEnumerator() | Sort-Object Name | ForEach-Object {
Write-Host (" {0,-12} : {1}" -f $_.Key, $_.Value)
}

# 盘点已安装的关键模块版本
$keyModules = @(
'Pester', 'PSFramework', 'PSScriptAnalyzer',
'platyPS', 'InvokeBuild', 'PSChecker',
'Microsoft.PowerShell.SecretManagement'
)

Write-Host "`n=== 关键模块版本 ===" -ForegroundColor Cyan
foreach ($mod in $keyModules) {
$installed = Get-Module -ListAvailable -Name $mod -ErrorAction SilentlyContinue |
Sort-Object Version -Descending | Select-Object -First 1
if ($installed) {
Write-Host (" {0,-50} v{1}" -f $mod, $installed.Version)
}
else {
Write-Host (" {0,-50} [未安装]" -f $mod) -ForegroundColor DarkGray
}
}

# 统计脚本文件数量(假设在项目目录中)
$projectDir = $PWD.Path
$scriptFiles = @(
Get-ChildItem -Path $projectDir -Filter '*.ps1' -Recurse -ErrorAction SilentlyContinue
Get-ChildItem -Path $projectDir -Filter '*.psm1' -Recurse -ErrorAction SilentlyContinue
)
Write-Host ("`n=== 项目统计 ===" -ForegroundColor Cyan)
Write-Host (" 脚本文件总数 : {0}" -f $scriptFiles.Count)
Write-Host (" 代码行数合计 : {0}" -f (
$scriptFiles | ForEach-Object { (Get-Content $_.FullName -ErrorAction SilentlyContinue).Count } |
Measure-Object -Sum | Select-Object -ExpandProperty Sum
))

执行结果示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
=== PowerShell 运行环境 ===
Edition : Core
OS : Unix 25.4.0
Platform : Unix
Version : 7.5.0

=== 关键模块版本 ===
Pester v6.0.4
PSFramework v1.12.0
PSScriptAnalyzer v1.23.0
platyPS v0.14.2
InvokeBuild v5.12.1
PSChecker [未安装]
Microsoft.PowerShell.SecretManagement v1.1.0

=== 项目统计 ===
脚本文件总数 : 47
代码行数合计 : 3216

AI 集成与云原生实战

2025 年最显著的变化之一,是 AI API 的调用门槛大幅降低。PowerShell 原生的 Invoke-RestMethod 已经能轻松完成与大模型的交互,社区也涌现了 PSOpenAIPode 等优秀的封装模块。在云原生领域,kubectldocker 与 PowerShell 的组合使用已经成为日常操作,跨平台执行也不再是障碍。

下面展示一段综合了 AI 调用和容器管理的实用脚本,帮助你快速理解当前主流的集成模式。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# 示例 1:调用 OpenAI 兼容 API 进行日志异常分析
function Invoke-AILogAnalysis {
[CmdletBinding()]
param(
[Parameter(Mandatory)]
[string]$LogContent,

[Parameter()]
[string]$Endpoint = 'http://localhost:11434/v1/chat/completions',

[Parameter()]
[string]$Model = 'qwen2.5:7b',

[Parameter()]
[int]$MaxTokens = 1024
)

$body = @{
model = $Model
messages = @(
@{
role = 'system'
content = '你是一名资深运维工程师,擅长分析系统日志中的异常模式。请用中文回复,列出关键异常和建议处理方案。'
}
@{
role = 'user'
content = "请分析以下日志内容中的异常:`n`n$LogContent"
}
)
max_tokens = $MaxTokens
temperature = 0.3
} | ConvertTo-Json -Depth 5

$result = Invoke-RestMethod -Uri $Endpoint -Method Post -Body $body `
-ContentType 'application/json; charset=utf-8' `
-ErrorAction Stop

return $result.choices[0].message.content
}

# 示例 2:跨平台容器状态巡检
function Get-ContainerHealthReport {
[CmdletBinding()]
param(
[Parameter()]
[string]$DockerHost = 'localhost'
)

$containers = docker ps -a --format '{{.Names}}|{{.Status}}|{{.Image}}|{{.Ports}}' 2>$null

if (-not $containers) {
Write-Warning "未检测到运行中的容器,请确认 Docker 服务是否已启动。"
return
}

$report = $containers | ForEach-Object {
$parts = $_ -split '\|'
[PSCustomObject]@{
Name = $parts[0]
Status = $parts[1]
Image = $parts[2]
Ports = $parts[3]
IsHealthy = $parts[1] -match '^Up'
}
}

$report | Format-Table -AutoSize
Write-Host ("健康容器: {0}/{1}" -f ($report | Where-Object IsHealthy).Count, $report.Count) `
-ForegroundColor Green
}

# 执行巡检
Get-ContainerHealthReport

执行结果示例:

1
2
3
4
5
6
7
8
9
Name            Status          Image              Ports       IsHealthy
---- ------ ----- ----- ---------
ollama Up 3 hours ollama/ollama 11434/tcp True
open-webui Up 3 hours ghcr.io/open-webui 8080/tcp True
postgres-db Up 5 days postgres:16 5432/tcp True
redis-cache Exited (0) 2h redis:7 6379/tcp False
nginx-proxy Up 3 hours nginx:alpine 80, 443 True

健康容器: 4/5

2026 技术展望与学习路线

展望 2026 年,几个清晰的趋势已经浮现:.NET 10 的发布将进一步提升 PowerShell 的运行时性能;AI Agent 模式(AI 自主调用工具、编排工作流)将深刻改变自动化脚本的编写方式;更多企业开始将 PowerShell DSC v3 与 Kubernetes Operator 结合,实现声明式基础设施管理。

以下脚本构建了一个个人技术雷达,帮助你梳理 2026 年的学习优先级。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# 2026 年 PowerShell 技术雷达
$techRadar = @(
[PSCustomObject]@{
Category = '核心语言'
Technology = 'PowerShell 7.6 / .NET 10'
Priority = '必须掌握'
Reason = '运行时性能提升、新 API 支持、源生成器优化'
}
[PSCustomObject]@{
Category = 'AI 集成'
Technology = 'AI Agent + Tool Calling'
Priority = '重点投入'
Reason = '大模型从辅助编码走向自主执行,需掌握 function calling 模式'
}
[PSCustomObject]@{
Category = '基础设施'
Technology = 'DSC v3 + K8s Operator'
Priority = '重点投入'
Reason = '声明式配置管理成为标准,DSC v3 与容器编排深度整合'
}
[PSCustomObject]@{
Category = '安全合规'
Technology = 'Crescendo + AppLocker'
Priority = '持续关注'
Reason = '零信任架构下脚本签名与执行策略管理更加重要'
}
[PSCustomObject]@{
Category = '测试工程'
Technology = 'Pester 6 + Test-Kitchen'
Priority = '必须掌握'
Reason = '基础设施即代码的测试覆盖度直接决定交付信心'
}
[PSCustomObject]@{
Category = '开发体验'
Technology = 'VS Code + Copilot + PSScriptAnalyzer'
Priority = '日常使用'
Reason = 'AI 辅助编码已成标配,结合静态分析确保质量'
}
)

Write-Host "=== 2026 PowerShell 技术雷达 ===" -ForegroundColor Cyan
$techRadar | Format-Table -AutoSize -Wrap

# 学习路线建议
$learningPath = @{
'Q1 (1-3月)' = '深入学习 PowerShell 7.6 新特性,掌握 .NET 10 互操作'
'Q2 (4-6月)' = '实践 AI Agent + Tool Calling,构建自动化运维助手'
'Q3 (7-9月)' = '学习 DSC v3,结合 Kubernetes 实现声明式配置管理'
'Q4 (10-12月)' = '完善 CI/CD 流水线,提升测试覆盖率和文档质量'
}

Write-Host "`n=== 推荐学习路线 ===" -ForegroundColor Cyan
$learningPath.GetEnumerator() | Sort-Object Name | ForEach-Object {
Write-Host (" {0} : {1}" -f $_.Key, $_.Value) -ForegroundColor Yellow
}

# 推荐学习资源
Write-Host "`n=== 推荐资源 ===" -ForegroundColor Cyan
$resources = @(
'官方文档: learn.microsoft.com/powershell'
'社区博客: devblogs.microsoft.com/powershell'
'开源项目: github.com/PowerShell'
'实战课程: PowerShell Conference EU 视频'
'AI 实践: Ollama + Open WebUI 本地大模型环境'
)
$resources | ForEach-Object { Write-Host " - $_" }

执行结果示例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
=== 2026 PowerShell 技术雷达 ===

Category Technology Priority Reason
-------- ----------- -------- ------
核心语言 PowerShell 7.6 / .NET 10 必须掌握 运行时性能提升、新 API 支持、源生成器优化
AI 集成 AI Agent + Tool Calling 重点投入 大模型从辅助编码走向自主执行...
基础设施 DSC v3 + K8s Operator 重点投入 声明式配置管理成为标准...
安全合规 Crescendo + AppLocker 持续关注 零信任架构下脚本签名与执行策略管理...
测试工程 Pester 6 + Test-Kitchen 必须掌握 基础设施即代码的测试覆盖度...
开发体验 VS Code + Copilot 日常使用 AI 辅助编码已成标配...

=== 推荐学习路线 ===
Q1 (1-3月) : 深入学习 PowerShell 7.6 新特性,掌握 .NET 10 互操作
Q2 (4-6月) : 实践 AI Agent + Tool Calling,构建自动化运维助手
Q3 (7-9月) : 学习 DSC v3,结合 Kubernetes 实现声明式配置管理
Q4 (10-12月): 完善 CI/CD 流水线,提升测试覆盖率和文档质量

=== 推荐资源 ===
- 官方文档: learn.microsoft.com/powershell
- 社区博客: devblogs.microsoft.com/powershell
- 开源项目: github.com/PowerShell
- 实战课程: PowerShell Conference EU 视频
- AI 实践: Ollama + Open WebUI 本地大模型环境

注意事项

  1. 保持版本同步:生产环境建议统一使用 PowerShell 7.x LTS 版本,避免 5.1 和 7.x 的行为差异导致脚本在不同环境执行结果不一致。重点关注 ConvertFrom-JsonInvoke-WebRequest 等命令在两个版本间的差异。

  2. AI 辅助需要验证:大模型生成的代码虽然越来越准确,但仍然会产生幻觉。关键逻辑必须人工审查,敏感操作(删除、修改配置)务必增加确认步骤。把 AI 当作高效的初稿生成器,而不是最终的代码审查者。

  3. 安全基线不可忽视:2025 年发生的多起供应链安全事件提醒我们,脚本的执行策略、模块来源验证和凭据管理必须作为常规检查项。定期使用 Get-AuthenticodeSignature 验证脚本签名,用 Get-InstalledModule 审计模块来源。

  4. 测试先行:无论是 AI 生成的代码还是手写脚本,上线前都应该通过 Pester 测试。2026 年建议将测试覆盖率目标设定为至少 80%,关键业务脚本达到 100%。Pester 6BeforeDiscovery 和参数化测试功能值得深入学习。

  5. 跨平台兼容意识:随着 Linux 和 macOS 上 PowerShell 使用率持续增长,编写脚本时应养成使用 Join-Path 替代硬编码路径分隔符、避免依赖 Windows 专属命令的习惯。$IsWindows$IsLinux$IsMacOS 变量可以帮助你编写跨平台兼容的代码。

  6. 持续学习与社区参与:PowerShell 生态演进速度在加快,2026 年建议每周至少花 2 小时阅读 release notes 和社区博客。参与 GitHub Discussions、提交 Issue 或 PR 是跟上技术节奏的最佳方式。关注 PowerShell Team 的官方博客和年度路线图更新,可以让你的学习方向更加明确。