forked from hashicorp/vagrant
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix the windows hyperv smb synced folder creation/destruction
closes hashicorp#12639
- Loading branch information
Showing
3 changed files
with
22 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,36 @@ | ||
Set-StrictMode -Version Latest | ||
$ErrorActionPreference = 'Stop' | ||
|
||
# The names of the user are language dependent! | ||
$objSID = New-Object System.Security.Principal.SecurityIdentifier("S-1-1-0") | ||
$objUser = $objSID.Translate([System.Security.Principal.NTAccount]) | ||
|
||
$grant = "$objUser,Full" | ||
|
||
for ($i=0; $i -le $args.length; $i = $i + 3) { | ||
for ($i = 0; ($i+2) -lt $args.length; $i = $i + 3) { | ||
$path = $args[$i] | ||
$share_name = $args[$i+1] | ||
$share_id = $args[$i+2] | ||
|
||
|
||
if ($path -eq $null) { | ||
Write-Warning "empty path argument encountered - complete" | ||
exit 0 | ||
if (!$path) { | ||
Write-Error "error - no share path provided" | ||
exit 1 | ||
} | ||
|
||
if ($share_name -eq $null) { | ||
if (!$share_name) { | ||
Write-Output "share path: ${path}" | ||
Write-Error "error - no share name provided" | ||
exit 1 | ||
} | ||
|
||
if ($share_id -eq $null) { | ||
if (!$share_id) { | ||
Write-Output "share path: ${path}" | ||
Write-Error "error - no share ID provided" | ||
exit 1 | ||
} | ||
|
||
$result = net share $share_id=$path /unlimited /GRANT:$grant /REMARK:"${share_name}" | ||
if ($LastExitCode -ne 0) { | ||
$host.ui.WriteLine("share path: ${path}") | ||
$host.ui.WriteErrorLine("error ${result}") | ||
exit 1 | ||
} | ||
New-SmbShare ` | ||
-Name $share_id ` | ||
-Path $path ` | ||
-FullAccess $objUser ` | ||
-Description $share_name | ||
} | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
Set-StrictMode -Version Latest | ||
$ErrorActionPreference = 'Stop' | ||
|
||
ForEach ($share_name in $args) { | ||
$result = net share $share_name /DELETE /YES | ||
if ($LastExitCode -ne 0) { | ||
Write-Output "share name: ${share_name}" | ||
Write-Error "error - ${result}" | ||
exit 1 | ||
} | ||
Remove-SmbShare ` | ||
-Name $share_name ` | ||
-Force | ||
} | ||
Write-Output "share removal completed" | ||
exit 0 |