powershell - 在生产环境中做 Set-executionpolicy 的常见做法是什么?

标签 powershell powershell-2.0

向客户提供脚本时,除非他们设置了执行策略,否则脚本不会执行。

向客户提供脚本时的常见做法是什么?

set-executionpolicy 是否将作为脚本中的第一个命令运行,以便它可以毫无错误地执行,或者将捕获有关 set-executionpolicy 的某些文档。

我第一次向我们的客户提供 powershell 脚本。以前我只是用来在我们的环境中执行,所以我没有考虑。

有人请帮我了解一下

最佳答案

一种方法:

还发送一个 bat 文件作为 .ps1 的包装器,它将执行以下操作:

@powershell -ExecutionPolicy RemoteSigned -File script.ps1

关于powershell - 在生产环境中做 Set-executionpolicy 的常见做法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11716603/

相关文章:

powershell - 错误计数和$Error自动变量不一致

powershell-2.0 - 远程启用 Psremoting

powershell - 使用 PowerShell 解除阻止文件?

xml - 如何使用 Xml.Save 强制或指定编码类型?

powershell - 通过 vmware API 运行 powershell 时获取退出代码 0x80131029

validation - PowerShell : GetNewClosure() and Cmdlets with validation

powershell - 通过powershell协助获得值(value)的一部分

azure - 使用 powershell 获取 Azure Web/Function App 身份验证配置

xml - XML文件格式-删除杂散CRLF

c# - 在 PowerShell v2 中编译新类型 - Cookie Aware WebClient