我编写了一个 powershell 脚本,打算使用 Intune 将其部署到 50 台设备。该脚本会删除 Chrome 中的浏览器缓存数据。我尚未通过 Intune 进行部署。在测试机器上,我将脚本放在一个目录中并执行它。我收到以下错误:
File C:\scripts\deleteGoogleCache.ps1 cannot be loaded because running scripts is
disabled on this system. For more
information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?
LinkID=135170.
+ CategoryInfo : SecurityError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnauthorizedAccess
因此,我寻找解决方案。我应该以管理员身份运行 PowerShell。显然,我不会在每个设备上都以管理员身份运行 powershell。因此,我通过发出以下命令找到了另一个提示:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
我收到了以下回复。
Execution Policy Change
The execution policy helps protect you from scripts that you do not trust. Changing the
execution policy might expose
you to the security risks described in the about_Execution_Policies help topic at
https:/go.microsoft.com/fwlink/?LinkID=135170. Do you want to change the execution
policy?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"):
显然,我不会亲自前往每一台设备并按 [A] 表示全部“是”。
任何帮助都将不胜感激,我是 Powershell 新手。