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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
| function Test-PowerShellSkillLevel { [CmdletBinding()] param( [string]$UserName = $env:USERNAME )
$Domains = @( @{ Name = 'AI/LLM 集成' Weight = 15 Topics = @('OpenAI API 调用', '本地模型部署', 'Prompt 工程', 'RAG 检索增强') KeyCmds = @('Invoke-RestMethod', 'Microsoft.PowerShell.AI') } @{ Name = 'Azure 管理' Weight = 15 Topics = @('资源管理', 'Graph API', 'Monitor 仪表盘', '部署槽') KeyCmds = @('Get-AzResource', 'Get-AzAccessToken', 'Az.Websites') } @{ Name = '容器与编排' Weight = 12 Topics = @('Docker 管理', 'Kubernetes 交互', '容器监控', '镜像安全') KeyCmds = @('docker', 'kubectl', 'Invoke-WebRequest') } @{ Name = '安全与合规' Weight = 10 Topics = @('基线审计', '日志分析', '权限管理', '加密解密') KeyCmds = @('Get-AuditPolicy', 'Protect-CmsMessage', 'certutil') } @{ Name = '网络与 API' Weight = 10 Topics = @('REST API 调用', 'WebSocket', 'GraphQL', '速率限制') KeyCmds = @('Invoke-RestMethod', 'Invoke-WebRequest', 'HttpClient') } @{ Name = 'GitOps/CI/CD' Weight = 10 Topics = @('Git 工作流', 'GitHub Actions', '流水线自动化', '配置即代码') KeyCmds = @('git', 'gh', 'Invoke-Expression') } )
$Results = foreach ($Domain in $Domains) { $TopicScore = [math]::Round( ($Domain.Topics.Count / 4) * 70 + (Get-Random -Minimum 15 -Maximum 30), 1 ) $TopicScore = [math]::Min($TopicScore, 100) $CmdScore = [math]::Round( ($Domain.KeyCmds.Count / 2) * 60 + (Get-Random -Minimum 20 -Maximum 40), 1 ) $CmdScore = [math]::Min($CmdScore, 100) $FinalScore = [math]::Round($TopicScore * 0.6 + $CmdScore * 0.4, 1)
[PSCustomObject]@{ Domain = $Domain.Name Weight = $Domain.Weight TopicScore = $TopicScore CmdScore = $CmdScore FinalScore = $FinalScore Level = switch ($FinalScore) { { $_ -ge 90 } { 'Expert' } { $_ -ge 75 } { 'Advanced' } { $_ -ge 60 } { 'Intermediate' } default { 'Beginner' } } } }
$TotalWeight = ($Results.Weight | Measure-Object -Sum).Sum $WeightedTotal = [math]::Round( ($Results | ForEach-Object { $_.FinalScore * $_.Weight } | Measure-Object -Sum).Sum / $TotalWeight, 1 )
Write-Host "=== PowerShell 技能评估报告 ===" -ForegroundColor Cyan Write-Host "评估对象: $UserName" Write-Host "评估时间: $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" Write-Host "评估维度: $($Domains.Count) 个技术领域" Write-Host ""
$Results | Format-Table Domain, Weight, TopicScore, CmdScore, FinalScore, Level -AutoSize
Write-Host "加权总分: $WeightedTotal / 100" -ForegroundColor Green Write-Host ""
$WeakAreas = $Results | Where-Object { $_.FinalScore -lt 75 } | Sort-Object FinalScore
if ($WeakAreas) { Write-Host "--- 进阶方向推荐 ---" -ForegroundColor Yellow foreach ($Area in $WeakAreas) { $Recommendation = switch ($Area.Domain) { 'AI/LLM 集成' { '深入学习 Microsoft.PowerShell.AI 模块和 RAG 架构' } 'Azure 管理' { '重点关注 Az 模块的最新 API 和 Managed Identity' } '容器与编排' { '练习 Kubernetes HPA/VPA 自动扩缩容脚本编写' } '安全与合规' { '掌握 CIS Benchmark 自动化扫描脚本开发' } '网络与 API' { '学习 GraphQL 查询构建和分页处理' } 'GitOps/CI/CD' { '实践 GitHub Actions 复合 Action 和矩阵构建' } default { '继续通过实战项目巩固基础技能' } } '[{0}] 得分 {1} - {2}' -f $Area.Domain, $Area.FinalScore, $Recommendation } }
Write-Host "" Write-Host "--- 雷达图数据(JSON)---" -ForegroundColor Yellow $RadarData = $Results | ForEach-Object { @{ axis = $_.Domain; value = $_.FinalScore } } $RadarData | ConvertTo-Json -Depth 3 }
Test-PowerShellSkillLevel
|