question

DaveGray-0128 avatar image
0 Votes"
DaveGray-0128 asked IanXue-MSFT answered

Moving Powershell modules to local drive

Hello

I have my Azure Az PowerShell (PS) modules installed on a network share for some reason and this means that every time
I run anything it takes minutes whilst they are loaded.

I was therefore wondering if I could copy them to a local path and then setup a profile to use these.

$PROFILE | Get-Member -Type NoteProperty

89125-ps2.png


Though this seems not enough as either PS ISE or VS Code will continue to "look" in the network shares first.

So basically, what is the best way to have the Az.* modules locally and have PS always look to a local path?

Thanks


windows-server-powershell
image.png (1.8 KiB)
ps2.png (32.8 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AndreasBaumgarten avatar image
0 Votes"
AndreasBaumgarten answered DaveGray-0128 commented

Hi @DaveGray-0128 ,

could you please check the module path: $env:PSModulePath
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_psmodulepath?view=powershell-7.1

Depending of the output a modification of the Module Path might help:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_psmodulepath?view=powershell-7.1#modifying-psmodulepath


(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

Regards
Andreas Baumgarten

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hello
Yes I checked that and added a line in my Profile1.ps1 to remove the fileshare modules path. Makes no difference, when I restart PS the path list is
not persisted and ISE or VS Code trundle off to the fileshare for 15 mins.

0 Votes 0 ·

Did you modify C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1? Can you help to post your profile?

0 Votes 0 ·

Hi Andreas,

This is the (redacted) profile from C:\Windows\System32\WindowsPowerShell\v1.0\Profile.ps1

$env:PSModulePath = $env:PSModulePath -replace "$([System.IO.Path]::PathSeparator)'\\domain.com\fileshare\Redirection$\david.gray\Documents\WindowsPowerShell\Modules'

$Env:PSModulePath.split(';')

Thanks

0 Votes 0 ·
IanXue-MSFT avatar image
0 Votes"
IanXue-MSFT answered

Hi,

Please see if this works

 $env:PSModulePath = $env:PSModulePath.replace('\\domain.com\fileshare\Redirection$\david.gray\Documents\WindowsPowerShell\Modules;','')


Best Regards,
Ian Xue
============================================
If the Answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.