Script Functions not loading from One Drive Folder

I have an issue where if a script function either as a module or a .ps1 will not load in Powershell 5 or above if the file is in One Drive. It will simply fail silently. I have this issue in 1803 and 1809. Has anyone else had this issue? Just curious.

When you say the files are in onedrive, how are you importing it, can you show the code snippet you use to import it.

You can only load and use modules, that are installed on your system, or when you physically provide the full path to where the module resides.

Seeing you OneDive in your file explorer, is not a normal path for this sort of thing. If you are trying to do that, then you need to add the path to your PS paths.

Both of the below concepts don’t work.

[pre] import-module c:\users\foo\onedrive\bar.psm1[/pre]

[pre] import-module c:\users\foo\onedrive\bar.ps1[/pre]

Point of note. What you see in Windows Explorer is not the real path. It’s a translated thing.
If you want a real filesystem drive to OD, then you have to set that up. You do not say if this is ODP (personal) or ODB (business).
If it is the later, see this…

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). https://gallery.technet.microsoft.com/office/OneDriveMapper-automaticall-d7d498b0

Otherwise , this…

https://www.thewindowsclub.com/map-onedrive-network-drive-windows-10

I really don’t understand your use case for this, but, I am sure you have your reasons. I have tons of scripts / modules in my ODP/ODB, but I would never run them from there. I download, and set them on the host as normal.