计算机启动和关机时首先运行 Windows PowerShell 脚本

此策略设置确定 Windows PowerShell 脚本在计算机启动和关机期间是否先于非 Windows PowerShell 脚本运行。默认情况下,Windows PowerShell 脚本在非 Windows PowerShell 脚本之后运行。

如果启用此策略设置,则在每个适用的组策略对象(GPO)中,计算机启动和关机期间 Windows PowerShell 脚本将先于非 Windows PowerShell 脚本运行。

例如,假定出现以下情况:

有三个 GPO (GPO A、GPO B 和 GPO C)。GPO A 中启用了此策略设置。

GPO B 和 GPO C 中包含以下计算机启动脚本:

GPO B: B.cmd、B.ps1
GPO C: C.cmd、C.ps1

并假定有两台计算机: DesktopIT 和 DesktopSales。
对于 DesktopIT,GPO A、B 和 C 均适用。因此,对于 DesktopIT,GPO B 和 C 的脚本按以下顺序运行:

在 GPO B 中: B.ps1、B.cmd
在 GPO C 中: C.ps1、C.cmd

对于 DesktopSales,GPO B 和 C 适用,但 GPO A 不适用。因此,对于 DesktopSales,GPO B 和 C 的脚本按以下顺序运行:

在 GPO B 中: B.cmd、B.ps1
在 GPO C 中: C.cmd、C.ps1

注意: 此策略设置确定计算机启动和关机脚本在所有适用的 GPO 中的运行顺序。可以通过为 GPO 配置以下策略设置,在特定的 GPO 中覆盖指定脚本类型的此策略设置:

计算机配置\策略\Windows 设置\脚本(启动/关机)\启动
计算机配置\策略\Windows 设置\脚本(启动/关机)\关机

支持的平台: 至少为 Windows 7 或 Windows Server 2008 R2

Registry HiveHKEY_LOCAL_MACHINE
Registry PathSoftware\Microsoft\Windows\CurrentVersion\Policies\System
Value NameRunComputerPSScriptsFirst
Value TypeREG_DWORD
Enabled Value1
Disabled Value0

scripts.admx

管理模板(计算机)

管理模板(用户)