蓝色天空.知识 · 实践 · 创造
我的收藏
在线代码实验室

PowerShell 启动:产品、权限、版本和策略:本章独立本地实验

POWERSHELLWindows / PowerShell7.6.5 / 同包自有文件、进程、回环JSON;其它平台和管理环境待验powershell-start.ps1
powershell-start.ps110 行
. (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位状态和五范围读取;前后执行策略完全相同。

请结合实际环境逐项观察。

附件与关联工程包下载

下载课程关联工程包:PowerShell

课程关联工程包(登记关联16章) · 含当前章节或实例 · mbskycom202611a525.zip
SITE SEARCH

搜索教程、工具与资讯

热门搜索

JavaScriptJSON格式化正则表达式AI 编程AI 翻译AI导航专题标签
Esc 关闭

欢迎登录蓝色天空网

使用会员账号,继续你的学习