diff --git a/plugins/hosts/windows/cap/smb.rb b/plugins/hosts/windows/cap/smb.rb index fa4d8c72f..02e98da33 100644 --- a/plugins/hosts/windows/cap/smb.rb +++ b/plugins/hosts/windows/cap/smb.rb @@ -100,15 +100,21 @@ module VagrantPlugins ] end if !shares.empty? - machine.env.ui.warn("\n" + I18n.t("vagrant_sf_smb.uac.create_warning") + "\n") - sleep(UAC_PROMPT_WAIT) - result = Vagrant::Util::PowerShell.execute(script_path, *shares, sudo: true) - if result.exit_code != 0 - share_path = result.stdout.to_s.sub("share path: ", "") - raise SyncedFolderSMB::Errors::DefineShareFailed, - host: share_path, - stderr: result.stderr, - stdout: result.stdout + uac_notified = false + shares.each_slice(10) do |s_shares| + if !uac_notified + machine.env.ui.warn("\n" + I18n.t("vagrant_sf_smb.uac.create_warning") + "\n") + uac_notified = true + sleep(UAC_PROMPT_WAIT) + end + result = Vagrant::Util::PowerShell.execute(script_path, *s_shares, sudo: true) + if result.exit_code != 0 + share_path = result.stdout.to_s.sub("share path: ", "") + raise SyncedFolderSMB::Errors::DefineShareFailed, + host: share_path, + stderr: result.stderr, + stdout: result.stdout + end end end end diff --git a/test/unit/plugins/hosts/windows/cap/smb_test.rb b/test/unit/plugins/hosts/windows/cap/smb_test.rb index 234415e39..d94efec8f 100644 --- a/test/unit/plugins/hosts/windows/cap/smb_test.rb +++ b/test/unit/plugins/hosts/windows/cap/smb_test.rb @@ -228,6 +228,18 @@ Remark Not Vagrant Owned expect(machine.env.ui).not_to receive(:warn) end end + + context "when more than 10 shares are defined" do + let(:folders) { + Hash[12.times.map{|i| ["/path#{i}", {hostpath: "/host#{i}"}]}] + } + + after{ subject.smb_prepare(env, machine, folders, options) } + + it "should execute multiple powershell commands" do + expect(Vagrant::Util::PowerShell).to receive(:execute).twice.with(any_args, sudo: true) + end + end end describe ".get_smbshares" do