Welcome Forums General PowerShell Q&A Script Functions not loading from One Drive Folder

• This topic has 4 replies, 3 voices, and was last updated 1 year ago by
Participant
.
• Author
Posts
• #156737
Participant
Topics: 5
Replies: 5
Points: 15
Rank: Member

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.

• #156740
Senior Moderator
Topics: 8
Replies: 1215
Points: 4,334
Rank: Community Hero

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

• #157037
Participant
Topics: 2
Replies: 1013
Points: 2,093
Rank: Community Hero

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.

• #158298
Participant
Topics: 5
Replies: 5
Points: 15
Rank: Member

Both of the below concepts don’t work.

 import-module c:\users\foo\onedrive\bar.psm1

 import-module c:\users\foo\onedrive\bar.ps1

• #158300
Participant
Topics: 2
Replies: 1013
Points: 2,093
Rank: Community Hero

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…