Modifying PSModulePath

I am thinking this is a simple question but I have been unable to find an answer so far. I know how to "ADD" to the PSMosulePath but how do I take away? I have a path I need to remove from my PSModulePath variable and nothing I have tried so far seems to be working.

Thanks

January 17th, 2014 9:21pm

One way what i remember is Just setting the original value  like $env:psmodulepath = "original Value"

$env:psmodulepath
C:\Documents and Settings\user\My Documents\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\
$env:PSModulePath = $env:PSModulePath + ";c:\ModulePath"
$env:psmodulepath
C:\Documents and Settingsuser\My Documents\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\;c:\ModulePath
 $env:PSModulePath = "C:\Documents and Settings\adminam\My Documents\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\"
 $env:psmodulepath
C:\Documents and Settings\adminam\My Documents\WindowsPowerShell\Modules;C:\WINDOWS\system32\WindowsPowerShell\v1.0\Modules\

Even if you want to keep the module path for the Current session only

$env:PSModulePath += ";c:\ModulePath"

http://msdn.microsoft.com/en-us/library/dd878326(v=vs.85).aspx

Free Windows Admin Tool Kit Click here and download it now
January 18th, 2014 12:11am

try it this way:

   $delete = "C:\modules"
   $psmod = @()
   $env:PSmodulePath -split(";") | where {$_ -ne $delete} | foreach {$psmod += $_}
   $env:PSmodulepath = $psmod -join(";")

January 18th, 2014 12:57am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics