Fix for HyperV provider fails when recreating shares on Vagrant reload #3353
This commit is contained in:
parent
b52d60d178
commit
4d4c85b944
|
@ -8,14 +8,7 @@ Param(
|
||||||
|
|
||||||
$ErrorAction = "Stop"
|
$ErrorAction = "Stop"
|
||||||
|
|
||||||
# See all available shares and check alert user for existing/conflicting
|
if (net share | Select-String $share_name) {
|
||||||
# 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
|
net share $share_name /delete /y
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue