none
Mount OneDrive? RRS feed

  • Dotaz

  • How do I use PowerShell to mount my OneDrive as a local drive? This is for personal OneDrive, not OneDrive for Business. I've found methods for mounting OneDrive using Explorer and NET USE, but I couldn't get it to work with any of the obvious PowerShell cmdlets

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    sobota 19. října 2019 21:37

Odpovědi

  • Ok - a little technical investigation finds that this works on Win10 and later.

    $cid = 'your CID'
    $cred = Get-Credential youraccount@msn.com
    New-PSDrive -Name Z -PSProvider FileSystem -Root "\\d.docs.live.net@SSL\DavWWWRoot\$cid" -Credential $cred
    

    The same method with a different URL structure also work on OneDrive for Business.

    Only Win10 and later seem to have full WebDAV support although WebDAV has worked at least since XP against SharePoint 2010 and later.


    \_(ツ)_/

    • Označen jako odpověď Brian Catlin neděle 20. října 2019 0:25
    neděle 20. října 2019 0:22

Všechny reakce

  • One Drive is automatically replicated to the local account profile. It is "mounted" but, in regality, it is sync'd.

    Your question needs to be asked in the User General forum for Windows as it is not a scripting question.

    Personal "OneDrive" cannot be mounted.  The mountable URL is not exposed as it is in Business OneDrive.


    \_(ツ)_/

    sobota 19. října 2019 21:49
  • Here is the old answer which I do not believe works anymore.

    https://www.laptopmag.com/articles/map-onedrive-network-drive


    \_(ツ)_/

    sobota 19. října 2019 22:21
  • Yes, I know that, but I don't have everything replicated locally. It certainly is a scripting question, because OneDrive CAN be mapped. I want to know how to do it with PowerShell.

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    sobota 19. října 2019 22:26
  • Amazing. This still works. Just follow the instructions.

    Here are the simplified instructions:

    How to Map OneDrive as a Network Drive to See All Your Files
    1. Log into Onedrive.com.
    2. Copy the CID number from the address bar. ...
    3. In Windows Explorer, go to This PC.
    4. Click on the Computer tab then "Map network drive".
    5. In the Folder field, enter https://d.docs.live.net/ followed by the CID you copied in step 1.
    6. Check the "Connect using different credentials" box.


    \_(ツ)_/

    sobota 19. října 2019 22:28
  • Please move this back to PowerShell. If I can map the drive using Explorer or NET USE, there must be a way to do it with PowerShell


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog

    sobota 19. října 2019 22:28
  • You should have just asked in your search engine how to map a drive in PowerShell.

    NET USE also works in PowerShell

    help New-PsDrive -online


    \_(ツ)_/

    sobota 19. října 2019 22:33
  • Actually PS cannot do that with the above command. A little search gets us this method to map a drive with PowerShell using an online service (OneDrive).

    https://gallery.technet.microsoft.com/OneDriveMapper-automaticall-d7d498b0


    \_(ツ)_/

    sobota 19. října 2019 22:40
  • Yes, I already found that; it is for OneDrive for Business, not OneDrive personal

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog


    sobota 19. října 2019 23:00
  • They both require WebDAV and there is no WebDAV support in PowerShell or OneDrive personal. The same method will work but the URL building will differ so the code will have to be modified.


    \_(ツ)_/

    neděle 20. října 2019 0:15
  • Ok - a little technical investigation finds that this works on Win10 and later.

    $cid = 'your CID'
    $cred = Get-Credential youraccount@msn.com
    New-PSDrive -Name Z -PSProvider FileSystem -Root "\\d.docs.live.net@SSL\DavWWWRoot\$cid" -Credential $cred
    

    The same method with a different URL structure also work on OneDrive for Business.

    Only Win10 and later seem to have full WebDAV support although WebDAV has worked at least since XP against SharePoint 2010 and later.


    \_(ツ)_/

    • Označen jako odpověď Brian Catlin neděle 20. října 2019 0:25
    neděle 20. října 2019 0:22
  • Thanks!

    Please move this back to the PowerShell forum

     -Brian


    Azius Developer Training www.azius.com Windows device driver, internals, security, & forensics training and consulting. Blog at www.azius.com/blog


    neděle 20. října 2019 0:26
  • I can't move it back for some reason. Maybe someone else will.

    I decided to write a complete solution since one was not clearly available on the web.

    function Connect-OneDrivePersonal{
    	param(
    		[Parameter(Mandatory)]
    		$DriveTag,  			 # Any string of characters  (only A-Z if persisting.
    		[Parameter(Mandatory)]
    		$cid,
    		[Parameter(Mandatory)]
    		[pscredential]$Credential,
    		[switch]$Persist,
    		[string]$Scope = 'Global'
    	)
    	$davRoot = "\\d.docs.live.net@SSL\DavWWWRoot\$cid"
    	New-PSDrive -Name $DriveTag -PSProvider FileSystem -Root $davRoot -Credential $cred -Persist:$Persist -Scope $Scope
    }
    


    \_(ツ)_/

    neděle 20. října 2019 1:23