Skip to content

Instantly share code, notes, and snippets.

@KAllan357
Created April 12, 2013 02:26
Show Gist options
  • Save KAllan357/5368817 to your computer and use it in GitHub Desktop.
Save KAllan357/5368817 to your computer and use it in GitHub Desktop.
[default] -- /vagrant
[default] -- C:/mounted-packages
An error occurred executing a remote WinRM command.
Shell: powershell
Command: function which {
$command = [Array](Get-Command $args[0] -errorAction continue)
write-host $command[0].Definition
}
function test ([Switch] $d, [String] $path) {
Resolve-Path $path| Out-Null;
}
function chown {
exit 0
}
function mkdir ([Switch] $p, [String] $path)
{
if(Test-Path $path)
{
exit 0
} else {
New-Item $p -Type Directory -Force | Out-Null
}
}
function Test-ReparsePoint([string]$path) {
$file = Get-Item $path -Force -ea 0
return [bool]($file.Attributes -band [IO.FileAttributes]::ReparsePoint)
}
$MountPoint = [System.IO.Path]::GetFullPath("C:/mounted-packages")
$ShareName = "C:/mounted-packages"
# https://github.com/BIAINC/vagrant-windows/issues/4
# Not sure why this works, but it does.
& net use $ShareName 2>&1 | Out-Null
Write-Debug "Attempting to mount $ShareName to $MountPoint"
if( (Test-Path "$MountPoint") -and (Test-ReparsePoint "$MountPoint") )
{
Write-Debug "Junction already exists, so I will delete it"
# Powershell refuses to delete junctions, oh well use cmd
cmd /c rd "$MountPoint"
if ( $LASTEXITCODE -ne 0 )
{
Write-Error "Failed to delete symbolic link at $MountPoint"
exit 1
}
}
elseif(Test-Path $MountPoint)
{
Write-Debug "Mount point already exists and is not a symbolic link"
exit 1
}
$BaseDirectory = [System.IO.Path]::GetDirectoryName($MountPoint)
if (-not (Test-Path $BaseDirectory))
{
Write-Debug "Creating parent directory for mount point $BaseDirectory"
New-Item $BaseDirectory -Type Directory -Force | Out-Null
}
cmd /c mklink /D "$MountPoint" "\\vboxsrv\$ShareName" | out-null
if ( $LASTEXITCODE -ne 0 )
{
exit 1
}
Message: translation missing: en.vagrant.errors.winrm_bad_exit_status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment