Skip to content

Instantly share code, notes, and snippets.

@JasonMorgan
Last active December 3, 2016 15:09
Show Gist options
  • Save JasonMorgan/a2f0231d815b1c0c52e14cfd10d43c1f to your computer and use it in GitHub Desktop.
Save JasonMorgan/a2f0231d815b1c0c52e14cfd10d43c1f to your computer and use it in GitHub Desktop.
function Get-OneDriveUrl {
param (
$sharingUrl
)
$base64Value = [System.Convert]::ToBase64String( [System.Text.Encoding]::UTF8.GetBytes($sharingUrl) )
$encodedUrl = "u!" + $base64Value.TrimEnd('=').Replace('/','_').Replace('+','-')
(Invoke-RestMethod -Uri "https://api.onedrive.com/v1.0/shares/$encodedUrl/root?expand=children").'@content.downloadUrl'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment