Skip to content

Instantly share code, notes, and snippets.

@davecan
Created March 23, 2016 23:36
Show Gist options
  • Save davecan/7203ce7b9a76990ffb62 to your computer and use it in GitHub Desktop.
Save davecan/7203ce7b9a76990ffb62 to your computer and use it in GitHub Desktop.
Simple powershell function that returns the path to a local personal dropbox instance.
function GetDropboxPath
{
$jsonPartialPath = "\Dropbox\info.json"
$jsonAppdataPath = $env:APPDATA + $jsonPartialPath
$jsonLocalAppdataPath = $env:LOCALAPPDATA + $jsonPartialPath
if (test-path $jsonAppdataPath)
{
$jsonPath = $jsonAppdataPath
}
elseif (test-path $jsonLocalAppdataPath)
{
$jsonPath = $jsonLocalAppdataPath
}
else
{
throw "Neither JSON path is reachable. Is Dropbox installed? See: https://www.dropbox.com/help/4584"
}
$json = (get-content $jsonPath | convertfrom-json)
return $json.personal.path
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment