此策略设置确定 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 设置\脚本(启动/关机)\关机
Registry Hive | HKEY_LOCAL_MACHINE |
Registry Path | Software\Microsoft\Windows\CurrentVersion\Policies\System |
Value Name | RunComputerPSScriptsFirst |
Value Type | REG_DWORD |
Enabled Value | 1 |
Disabled Value | 0 |