Issue running module, have to import every time

Jun 2, 2011 at 11:15 PM

I am looking for some advice on running the poweshell module "HyperV"

I ran the install.cmd after setting the zip to Unblock and extracting the files , they have extracted to:

C:\Program Files\modules\HyperV

 

WHen I launch powershell if I run the command nothing is listed

get-command -module HyperV

 

I have to run the Import-Module "C:\Program Files\modules\HyperV\HyperV.psd1"

Once I have imported the module it works ok until I close and re-open Powershell.

 

What am I missing that makes these settings persistent ?

Jun 13, 2011 at 9:36 PM

Same thing for me...

 

bump..

Jun 14, 2011 at 11:18 AM

Hi,

As far as I know, modules unload every time PowerShell session ends, therefore they need to be re-imported again. I believe it's "by design" thing.

Jun 14, 2011 at 11:42 AM

Thank you.

I read something about import modules into your profile, so when powershell is started, your modules are loaded.  I will look into that.  I use the powershells for hyper-v as I can't reliably connect to the Hyper-V Manager due to RPC error, when connecting though our VPN.

 

Cheers

 

Jun 16, 2011 at 3:40 AM

Jim is right just put Import-module HyperV in your profile so everytime you would open powershell the module would be automatically loaded

Jun 21, 2011 at 5:17 PM

Same issue for me. It creates a major problem when you try to do scripting with this module.

Jun 21, 2011 at 5:23 PM
Edited Jun 21, 2011 at 9:38 PM

Never mind.. i figured the script out with this module.

Jul 20, 2011 at 9:35 AM

powershell -c "set-executionpolicy bypass -force"
if not exist "C:\windows\System32\WindowsPowerShell\v1.0\Modules\HyperV" (robocopy D:\HyperV  C:\windows\System32\WindowsPowerShell\v1.0\Modules\HyperV *.* & PowerShell.exe -Command "& {echo 'Import-Module HyperV.psd1' >> $profile.AllUsersAllHosts}" )

powershell -c "get-vm -running"