PsOneDriveProvider is a sample implementation of OneDrive provider for PowerShell, intended to showcase:
- How to implement a PowerShell provider
- How to use RESTful API to access OneDrive
THIS MODULE IS NOT INTENDED FOR PRODUCTION USE.
- Download the source code (somehow)
- Open the solution file and build the solution
- Run Tools\Install.ps1 to install the OneDrive module to to $HOME\Documents\WindowsPowerShell\Modules
To execute this sample code, you need to obtain a set of Live SDK client Id and secret by registreing a new application at Live Connect Develoepr Center:
You need to register your application as a mobile client app / desktop client app.
Once you obtain your client Id and secret, configure OneDrive module to use them.
- Import-Module Awagat.OneDrive
- Set-OdClientProfile -Id your-client-id -Secret your-client-secret
- Import-Module Awagat.OneDrive
- New-PSDrive -Name drive-name -Provider OneDrive -Root \
In PowerShell, Copy-Item / Move-Item only works within the same provider. Use Get-Content and Set-Content to copy files between file system and OneDrive providers.
In this implementation, you can only specify a destination folder path for Copy-Item and Move-Item, and you cannot include the destination file name in it. This restriction comes from some limitation on how MOVE and COPY method behave in Live SDK REST API.