Scripts and OneDrive

Is there a way to run a script from a OneDrive folder?

I work both from the office and from home. Rather than remoting into my pc at the office or having duplicate folders with duplicate sets of scripts which I sometimes forget to update, it would be nice to be able to just have one folder with all my scripts and source files etc. on OneDrive.

I have been unsuccessful in finding a way to map a OneDrive folder to a drive letter however.

Any suggestions? Flash drives are out as they are encrypted with BitLocker and using them is a royal pain.

If you are using the OneDrive Sync Client, then you have a local folder to run your scripts from without the need to map it with a drive letter. I run scripts from my onedrive all the time without issue. OneDrive syncs my script folder across two machines I use for work.

Why the need to map a drive to OneDrive? OneDrive already syncs to your PC.

Just copy all your script folder to your OneDrive folder, it sync’s as expected, and using the normal map drive or New-PSDrive, you should be able to map. So, I am curious as to what you’ve tried that you say has failed.

PSDrive notwithstanding, you’ve always been able to map a local drive to OneDrive, though doing so is a bit convoluted.
There have been lots of articles on how to do that since Win7 days.

Example of some:

I have had trouble running scripts when the path is several folders long. ie: c:\users\username\OneDrive - CompanyName, Inc.\foldername\foldername


I suspect it has to do with how the naming works for our OneDrive. Literally OneDrive - CompanyName, Inc.

So mapping the scripts folder to a drive letter would be ideal.


This is a corporate OneDrive. Not a personal one.

You can still map a drive to ODfB

OneDriveMapper automatically map your OneDrive for Business upon login
This script maps your Onedrive / Sharepoint / Teams document libraries to driveletters (or shortcuts). It can be used in any environment (VDI, RemoteApp, w10 etc).

After reading these details:

“…Finally, mapping has severe limitations (speed, size limits, reliability), if you need a highly available solution, Freek Berson wrote a good article “I got your OneDrive for Business Sync right here!” on using a containerized solution with the actual, full Onedrive client and experience using FSLogix. …”

I doubt I would use this and FLogix would have to be purchased which is not really a good fit.

Thanks for the info though.