From 4d4c85b9440e5a1ed275553c3ef620424ada40ab Mon Sep 17 00:00:00 2001 From: Pierre Jacomet Date: Sat, 29 Mar 2014 18:15:24 -0700 Subject: [PATCH] Fix for HyperV provider fails when recreating shares on Vagrant reload #3353 --- plugins/synced_folders/smb/scripts/set_share.ps1 | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/plugins/synced_folders/smb/scripts/set_share.ps1 b/plugins/synced_folders/smb/scripts/set_share.ps1 index ac49d1c83..469483f38 100644 --- a/plugins/synced_folders/smb/scripts/set_share.ps1 +++ b/plugins/synced_folders/smb/scripts/set_share.ps1 @@ -8,15 +8,8 @@ Param( $ErrorAction = "Stop" -# See all available shares and check alert user for existing/conflicting -# share names. -$path_regexp = [System.Text.RegularExpressions.Regex]::Escape($path) -$name_regexp = [System.Text.RegularExpressions.Regex]::Escape($share_name) -$reg = "(?m)$name_regexp\s+$path_regexp\s" -$existing_share = $($(net share) -join "`n") -Match $reg -if ($existing_share) { - # Always clear the existing share name and create a new one - net share $share_name /delete /y +if (net share | Select-String $share_name) { + net share $share_name /delete /y } # The names of the user are language dependent!