-
Notifications
You must be signed in to change notification settings - Fork 100
Description
Summary of the new feature / enhancement
As an user in a very restricted environment I cannot use PowerShell Core V7 on Windows 10 because of the following reasons acting simultaneously:
- I do not have Local Admin rights to the desktop as per corporate policy
- PowerShell Core will install all modules (
Install-Module -Scope CurrentUser -Name SomeModule
) to theC:\Users\johndoe\Documents\PowerShell\Modules
regardless of the$env:PSModulePath
- The
Documents
folder hierarchy has a corporate Anti-Virus policy and does not allow any DLL/EXE/.BAT/PS1/.VBS file to be executed. Therefore,install-module
appears to work, but PWSH is unable to load any module.
All the above make it impossible to use any module thereby rendering PowerShell Core almost useless in my current work environment.
What workarounds did I try?
- I installed the ZIP download of PowerShell Core in a local folder
C:\Users\johndoe\mywork001
, outside ofDocuments
hierarchy to bypass Anti-Virus. - I tried tinkering with
$env:PSModulePath
in the vain hope that PWSH would start using the aforementioned folder for installing modules. - I tried altering the
powershell.config.json
as per this link , but this too did not work
Possible solution - inspired by NPM
Taking inspiration from Node Package Manager works (NPM) , PowerShell Core should not rely on a hard wired set of folder(s) for installing modules. Instead, it should be allowed to use the current working directory. Think of a package.json
in the case of NPM and the JavaScript modules get installed in the node_modules
sub-folder of the current working directory
Possible solution - inspired by powershell.config.json
I should be able to create a powershell.config.json in any folder c:\users\johndoe\mywork001\
and able to run pwsh.exe
located in another folder by specifying the absolute path to the powershel.config.json as a command line argument. The PWSH.exe instance should follow the directions of the configuration file and install modules accordingly
Overarching idea
Make PWSH free from the shackles of CurrentUser and AllUsers scope. The CurrentUser/AllUser could still be retained as good to have options. I should be able to run side by side copies of PWSH using different versions of Modules , just like XCOPY of .NET or NODE.JS.
Proposed technical implementation details (optional)
Installing a module locally could look something like the following:
install-module -Name SqlServer -Scope Local
If this were NPM, then you would do the following:
npm install sqlserver
You will see the entry of SqlServer
getting added to package.json
and the Jascript code downloaded to node_modules
folder.
The benefit of package.json
is the ability to have SCM on your environment. You can reproduce your working folder by simply doing a npm install
and all the packages listed in package.json
will get downloaded with the right versions.
No response