我有一个用于创建 Outlook 签名的 powershell 脚本。它通过用户分配的 GPO 应用。所有用户都在同一个 OU 中,组策略对象链接到该 OU。
政府采购组织(GPO):
User Configuration (Enabled)hide
Policieshide
Windows Settingshide
Scriptshide
Logonhide
For this GPO, Script order: Windows PowerShell scripts will run firstName Parameters
SignatureUnifiedFull v2.ps1
它在 Windows 10 设备上运行完美,但 Windows 7 设备无法运行它(即使我在设备上手动运行脚本时它可以运行)。
我运行了 GPresult /R,策略确实出现在那里......
Windows 7 和 Windows 10 运行登录脚本的方式有何不同?
答案1
我想到了!
该脚本的名称中有一个空格。我删除了空格,然后……它就正常工作了!
我不知道我是否应该因为没有早点弄清楚而感到愚蠢......
答案2
可能是因为 Windows 7 中的执行策略设置不同。尝试执行以下操作作为测试:创建 GPO,包含 .bat 文件,其中包含以下行:
powershell -noexit -c set-executionpolicy remotesigned -force
c:\pshell.ps1
使用“set-executionpolicy default -force”结束你的 PS 脚本
答案3
我们在名称方面也遇到了类似的问题。我们正在升级环境(应用程序版本并从服务器 2008 迁移到 2012),并且知道我们的 GPO 脚本可以正常工作。显然 ps1 文件不能包含空格。