Created
March 23, 2016 23:36
-
-
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.
This file contains hidden or 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
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