. (Join-Path $PSScriptRoot 'lab.ps1')
$objects = @([pscustomobject]@{Name='read';Score=4},[pscustomobject]@{Name='build';Score=8})
$result = @($objects | Where-Object Score -gt 5 | Select-Object Name,Score)
Assert-Learning ($result.Count -eq 1 -and $result[0].Name -eq 'build') 'typed pipeline'
Assert-Learning ($result[0].Score -is [int]) 'integer retained'
$textRows = @($objects | ConvertTo-Csv -NoTypeInformation)
Assert-Learning ($textRows[0] -is [string]) 'serialized text is different'
$restored = @($textRows | ConvertFrom-Csv)
Assert-Learning ($restored[1].Score -is [string]) 'CSV loses number type without schema'
Write-LearningReport 'powershell-intro' @{object_type=$result[0].Score.GetType().Name;csv_type=$restored[1].Score.GetType().Name;object_score=$result[0].Score;not_all_commands_return_nontext=$true;bash_language_capabilities_not_dismissed=$true}
本例需在 Windows / PowerShell7.6.5 / 同包自有文件、进程、回环JSON;其它平台和管理环境待验 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:Windows / PowerShell7.6.5 / 同包自有文件、进程、回环JSON;其它平台和管理环境待验
入口文件:projects/powershell-lab/powershell-intro.ps1
预期结果与验证条件观察提示
- 结构化整数8保留,CSV往返后字段为字符串;类型与文本区别真实核对。
请结合实际环境逐项观察。
附件与关联工程包下载
课程关联工程包(登记关联16章) · 含当前章节或实例 · mbskycom202611a525.zip