在Vagrant中运行PowerShell脚本

时间:2016-08-05 12:46:54

标签: powershell vagrant

我使用此命令通过PowerShell在Vagrant中运行脚本

vagrant.exe powershell -c "SchTasks /Create /TN 'InstallTask' /SC ONCE /ST 23:59 /IT /RL HIGHEST /TR 'powershell -Command c:/vagrant/I_O.ps1' /F | Out-Host; SchTasks /Run /TN 'InstallTask' | Out-Host;"

但是只有当我从PowerShell ISE手动启动它并作为单独的命令时它才有效。

我想在这个脚本块中使用它

# Run Vagrant

vagrant up

# Run PowerShell in Vagrant

vagrant.exe powershell -c "Set-Location C:\vagrant"

#Set policy to Unrestricted

vagrant.exe powershell -c "Set-ExecutionPolicy Unrestricted -Force"

# Install Chocolatey

 vagrant.exe powershell -c "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"

# Turn off confirmation in Chocolatey

vagrant.exe powershell -c "chocolatey feature enable -n=allowGlobalConfirmation"

# Install .net 3.5

vagrant.exe powershell -c "choco install dotnet3.5 -force"

# Run O installation script

vagrant.exe powershell -c "SchTasks /Create /TN 'InstallTask' /SC ONCE /ST 23:59 /IT /RL HIGHEST /TR 'powershell -Command c:/vagrant/I_O.ps1' /F | Out-Host; SchTasks /Run /TN 'InstallTask' | Out-Host;"

0 个答案:

没有答案