-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathGet-PSModulePath.ps1
29 lines (22 loc) · 1.41 KB
/
Get-PSModulePath.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# http://wahlnetwork.com/2015/08/10/psmodulepath/
Write-Output -InputObject "User Environment Variable PSModulePath:"
[Environment]::GetEnvironmentVariable('PSModulePath','User') -split ';'
Write-Output -InputObject ''
Write-Output -InputObject "Machine Environment Variable PSModulePath:"
[Environment]::GetEnvironmentVariable('PSModulePath','Machine') -split ';'
Write-Output -InputObject ''
Write-Output -InputObject "Process Environment Variable PSModulePath:"
[Environment]::GetEnvironmentVariable('PSModulePath','Process') -split ';'
<#
# Reset / overwrite to original PSModulePath values
$PSModulePath = "${env:ProgramFiles(x86)}\WindowsPowerShell\Modules;$env:SystemRoot\system32\WindowsPowerShell\v1.0\Modules;$env:ProgramFiles\WindowsPowerShell\Modules;$env:USERPROFILE\Documents\WindowsPowerShell\Modules"
# OR
#Save the current value in the $p variable.
$p = [Environment]::GetEnvironmentVariable('PSModulePath','User')
#Add the new path to the $p variable. Begin with a semi-colon separator.
$p += ";$Home\Documents\WindowsPowerShell\Modules"
#Add the paths in $p to the PSModulePath value.
[Environment]::SetEnvironmentVariable('PSModulePath',$p,'User')
# Requres admin rights to set/reset Machine level
[Environment]::SetEnvironmentVariable('PSModulePath',"${env:ProgramFiles(x86)}\WindowsPowerShell\Modules;$env:SystemRoot\system32\WindowsPowerShell\v1.0\Modules;$env:ProgramFiles\WindowsPowerShell\Modules",'Machine')
#>