我不确定从哪里开始解决这个问题。我正在使用 modernIE\w7-ie8
盒子。我第一次启动它(vagrant up
从头开始),需要手动调整它才能让 Vagrant 连接:
- 通过启动恢复/修复对话框继续/取消
- 将网络类型从公共(public)更改为工作/家庭
之后,我有三个简短的 shell 提供语句:注册一些 DLL,安装 Chocolatey ,并安装 Chocolatey 包。
Vagrant 文件:
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%"
最佳答案
我认为#3816是答案。它对我有用。将 privileged: false
添加到 provision
调用的末尾,应该可以做到。
config.vm.provision "shell", inline: "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))", privileged: false
关于windows - 为什么在删除 WinRM 日志时 Windows guest 配置失败?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34908123/