在 MDT 2013 中将 PowerShell 脚本作为应用程序运行

Jas*_*son 5 windows powershell mdt windows-server-2012-r2

有没有办法让 powershell 脚本在应用程序列表下运行,这样当您从 MDT 映像安装时,您可以选择要运行的脚本?

我可以将脚本作为脚本很好地运行,但是我尝试过的每次尝试脚本都不会执行。

这就是我试图做到的,但他们不执行。(我链接到任务序列下的安装应用程序下的脚本。到目前为止,我得出的结论是 Microsoft 不允许 PowerShell 脚本以这种方式工作,而没有一些严重的黑客攻击。

在此处输入图片说明

编辑:

因此,在尝试了多种方法并进行了研究之后,这就是我现在所拥有的:

我正在尝试这个:

powershell -noexit "& "'\\SERVER.com\ImageDeploymentShare$\Scripts\script_tes_2t.ps1'
Run Code Online (Sandbox Code Playgroud)

工作目录是:

.\%SCRIPTROOT%
Run Code Online (Sandbox Code Playgroud)

但我得到了这个: 在此处输入图片说明

我在technet上看到过类似的帖子,但这肯定是极端的吗?

Filename RunPowerShell.cmd
Powershell -Command Set-ExecutionPolicy Unrestricted
Powershell.exe -file "%~dp0%1"
Powershell -Command Set-ExecutionPolicy AllSigned

Filename App1.ps1
Dir

Execute this with
[fulle_Path_if_needed\]RunPowerShell.cmd App1.ps1
Run Code Online (Sandbox Code Playgroud)

Nit*_*itz 4

我不了解 MDT,但从命令行运行位于 UNC 的 PowerShell 脚本类似于powershell -ExecutionPolicy bypass -file \\path\to\file.ps1.
它可以从 cmd 运行(没有任何安全提示):

从命令行运行基于 UNC 的 PowerShell 脚本