. (Join-Path $PSScriptRoot 'lab.ps1')
$before = @(Get-ExecutionPolicy -List | ForEach-Object { [string]$_.Scope+':'+[string]$_.ExecutionPolicy })
$effective = [string](Get-ExecutionPolicy)
$hostInfo = [pscustomobject]@{Version=$PSVersionTable.PSVersion.ToString();Edition=$PSVersionTable.PSEdition;Is64Bit=[Environment]::Is64BitProcess}
Assert-Learning ($hostInfo.Edition -eq 'Core') 'not ISE/Desktop assumption'
$after = @(Get-ExecutionPolicy -List | ForEach-Object { [string]$_.Scope+':'+[string]$_.ExecutionPolicy })
Assert-Learning (($before -join ',') -eq ($after -join ',')) 'policy remained unchanged'
Assert-Learning ($before.Count -eq 5) 'all scopes observed'
Write-LearningReport 'powershell-start' @{host=$hostInfo;effective_policy=$effective;policy_scope_names=@('MachinePolicy','UserPolicy','Process','CurrentUser','LocalMachine');policy_unchanged=$true;uac_service_or_remote_actions=$false;current_user_is_persistent_not_process_only=$true}
本例需在 Windows / PowerShell7.6.5 / 同包自有文件、进程、回环JSON;其它平台和管理环境待验 中运行,请复制源码、保存文件或下载工程包后在本地执行验证。
运行说明与环境独立工程
运行环境:Windows / PowerShell7.6.5 / 同包自有文件、进程、回环JSON;其它平台和管理环境待验
入口文件:projects/powershell-lab/powershell-start.ps1
预期结果与验证条件观察提示
- 运行版本、64位状态和五范围读取;前后执行策略完全相同。
请结合实际环境逐项观察。
附件与关联工程包下载
课程关联工程包(登记关联16章) · 含当前章节或实例 · mbskycom202611a525.zip