为什么删除WinRM日志时Windows来宾资源调配失败?
我不知道从哪里开始解决这个问题。我在用这个盒子。我第一次启动它(为什么删除WinRM日志时Windows来宾资源调配失败?,windows,powershell,vagrant,winrm,Windows,Powershell,Vagrant,Winrm,我不知道从哪里开始解决这个问题。我在用这个盒子。我第一次启动它(vagrant up从头开始),需要手动调整它以使vagrant连接: 通过启动恢复/修复对话框继续/取消 将网络类型从公共更改为工作/家庭 之后,我有三个简短的shell提供语句:注册一些DLL、安装和安装一个chocolate包 流浪汉档案: config.vm.provision "shell", inline: "regsvr32 foo/Foo.dll" config.vm.provision "shell", inl
vagrant up
从头开始),需要手动调整它以使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
我想这就是答案。这对我有用。将privileged:false
添加到provision
调用的末尾应该可以
config.vm.provision "shell", inline: "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))", privileged: false
您是否尝试在脚本中的
del$out\u file
语句中添加-Force
。。。我假设它在C:\HashiCorp\Vagrant
的某个地方?我还不确定这是否是一个bug,因此提出了这样的问题,而不是GitHub的问题:)
config.vm.provision "shell", inline: "echo %COMPUTERNAME%"
config.vm.provision "shell", inline: "echo %COMPUTERNAME%"
config.vm.provision "shell", inline: "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))", privileged: false