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

有没有办法使PowerShell脚本在应用程序列表下运行,以便在从MDT映像安装时,可以select要运行的脚本?

我可以像脚本一样运行脚本,但是我尝试过的所有脚本都不会执行。

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

在这里输入图像说明

编辑:

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

我正在尝试这个:

powershell -noexit "& "'\\SERVER.com\ImageDeploymentShare$\Scripts\script_tes_2t.ps1' 

工作目录是:

 .\%SCRIPTROOT% 

但是我得到这个: 在这里输入图像说明

我在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 

    我不知道MDT,但powershell -ExecutionPolicy bypass -file \\path\to\file.ps1运行UNC位置的PowerShell脚本会像powershell -ExecutionPolicy bypass -file \\path\to\file.ps1
    它从cmd工作(没有任何安全提示):

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

    在您的应用程序的“安装安装命令”中:

     powershell.exe -executionpolicy bypass -noprofile -noninteractive -file ".\[yourscriptfile].ps1" 

    只是将ps1文件作为命令的主要问题是executionpolicy,因为默认是受限制的。 即使将执行策略更改为remotesigned脚本也不会运行,因为它是UNCpath。