Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"using module" with relative path, where script is located at a UNC location does not work. #20018

Open
5 tasks done
markr-rpc opened this issue Jul 24, 2023 · 2 comments
Open
5 tasks done
Assignees
Labels
Needs-Investigation The behavior reported in the issue is unexpected and needs further investigation. Needs-Triage The issue is new and needs to be triaged by a work group. WG-Engine core PowerShell engine, interpreter, and runtime

Comments

@markr-rpc
Copy link

Prerequisites

Steps to reproduce

"Using module" in a script does not work with a relative path if the script is stored at a UNC location.
The first line gives an error if the script is running from a UNC location, but works fine if I run it from C:\Temp.

If I change both paths to absolute UNC paths, like the second line, it will work from both locations.

using module .\CWPSModules\EnvironmentVariables
using module \fs1\xxx\Dev\Scripts_v4.0\CWPSModules\ClassesCW6

Expected behavior

Script runs properly when running from C:\Temp, but does not work when running the script from a UNC location.

The actual script is irrelevant, it is the "using module" with a relative path that is the problem.

Actual behavior

When running the script from a UNC location, the following error occurs. 

ParserError: \\fs1\xxx\Dev\Scripts_v4.0\GetTextFrom-EncryptedFile.ps1:1:1
Line |
   1 |  using module .\CWPSModules\EnvironmentVariables #Holds run-time Envir …
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Could not find the module '.\CWPSModules\EnvironmentVariables'.
PS Microsoft.PowerShell.Core\FileSystem::\\fs1\xxx\Dev\Scripts_v4.0>

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.5
PSEdition                      Core
GitCommitId                    7.3.5
OS                             Microsoft Windows 10.0.22621
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@markr-rpc markr-rpc added the Needs-Triage The issue is new and needs to be triaged by a work group. label Jul 24, 2023
@markr-rpc
Copy link
Author

markr-rpc commented Jul 25, 2023

It also works fine if I map a drive to the UNC location, then run the script from the mapped drive. However, I have multiple environments to run the scripts (dev, sandbox, production) and it is not practical for me to map drives for everyone who needs the scripts.

FYI: The scripts worked fine in Windows PowerShell 5.1 from a UNC location.

@daxian-dbw daxian-dbw added the WG-Engine core PowerShell engine, interpreter, and runtime label Jul 28, 2023
@markr-rpc
Copy link
Author

Is there any update on this issue?

@SeeminglyScience SeeminglyScience added WG-Security security related areas such as JEA Needs-Investigation The behavior reported in the issue is unexpected and needs further investigation. and removed WG-Security security related areas such as JEA labels Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Investigation The behavior reported in the issue is unexpected and needs further investigation. Needs-Triage The issue is new and needs to be triaged by a work group. WG-Engine core PowerShell engine, interpreter, and runtime
Projects
None yet
Development

No branches or pull requests

3 participants