我不知道从哪里开始解决这个问题。我正在使用modernIE\w7-ie8
框。我第一次启动它(从头开始vagrant up
),需要手动调整才能让Vagrant连接:
之后,我有三个简短的shell配置语句:注册一些DLL,安装Chocolatey,并安装一个Chocolatey包。
Vagrantfile:
config.vm.provision "shell", inline: "regsvr32 foo/Foo.dll"
config.vm.provision "shell", inline: "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))"
config.vm.provision "shell", inline: "choco install foo -y"
输出:
PS> vagrant provision
==> default: Running provisioner: shell...
default: Running: inline PowerShell script
==> default: Running provisioner: shell...
default: Running: inline PowerShell script
==> default: Remove-Item : Cannot remove item C:\Windows\Temp\WinRM_Elevated_Shell.log: The
==> default: process cannot access the file 'C:\Windows\Temp\WinRM_Elevated_Shell.log' becau
==> default: se it is being used by another process.
==> default: At C:\tmp\vagrant-elevated-shell.ps1:19 char:6
==> default: + del <<<< $out_file
==> default: + CategoryInfo : WriteError: (C:\Windows\Temp\WinRM_Elevated_Shel
==> default: l.log:FileInfo) [Remove-Item], IOException
==> default: + FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell
==> default: .Commands.RemoveItemCommand
The following WinRM command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
powershell -ExecutionPolicy Bypass -OutputFormat Text -file c:\tmp\vagrant-shell.ps1
Stdout from the command:
Stderr from the command:
Remove-Item : Cannot remove item C:\Windows\Temp\WinRM_Elevated_Shell.log: The
process cannot access the file 'C:\Windows\Temp\WinRM_Elevated_Shell.log' becau
se it is being used by another process.
At C:\tmp\vagrant-elevated-shell.ps1:19 char:6
+ del <<<< $out_file
+ CategoryInfo : WriteError: (C:\Windows\Temp\WinRM_Elevated_Shel
l.log:FileInfo) [Remove-Item], IOException
+ FullyQualifiedErrorId : RemoveFileSystemItemIOError,Microsoft.PowerShell
.Commands.RemoveItemCommand
我需要确认heredoc版本的行为:
config.vm.provision "shell", inline: <<-SCRIPT
regsvr32 foo/Foo.dll
iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))
choco install foo -y
SCRIPT
将脚本缩减为任何2个命令,即使只是echo
s:
config.vm.provision "shell", inline: "echo %COMPUTERNAME%"
config.vm.provision "shell", inline: "echo %COMPUTERNAME%"
答案 0 :(得分:3)
我认为#3816就是答案。它对我有用。将privileged: false
添加到provision
调用的末尾,应该这样做。
config.vm.provision "shell", inline: "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))", privileged: false