Default the WinRM shell provisioner to privileged (elevated)

This commit is contained in:
Shawn Neal 2014-04-30 19:35:02 -07:00
parent 490562f00a
commit 392269a8eb
1 changed files with 5 additions and 7 deletions

View File

@ -96,12 +96,10 @@ module VagrantPlugins
exec_path.gsub!('/', '\\') exec_path.gsub!('/', '\\')
exec_path = "c:#{exec_path}" if exec_path.start_with?("\\") exec_path = "c:#{exec_path}" if exec_path.start_with?("\\")
command = <<-EOH # For PowerShell scripts bypass the execution policy
$old = Get-ExecutionPolicy; command = "#{exec_path}#{args}"
Set-ExecutionPolicy Unrestricted -force; command = "powershell -executionpolicy bypass -file #{command}" if
#{exec_path}#{args}; File.extname(exec_path).downcase == '.ps1'
Set-ExecutionPolicy $old -force
EOH
if config.path if config.path
@machine.ui.detail(I18n.t("vagrant.provisioners.shell.running", @machine.ui.detail(I18n.t("vagrant.provisioners.shell.running",
@ -112,7 +110,7 @@ module VagrantPlugins
end end
# Execute it with sudo # Execute it with sudo
comm.sudo(command) do |type, data| comm.sudo(command, elevated: config.privileged) do |type, data|
handle_comm(type, data) handle_comm(type, data)
end end
end end