简体   繁体   中英

Not correctly importing modules via import-pssession

$HyperVServerSession = New-PSSession -Name SERVER
Import-PSSession -session $HyperVServerSession -Module hyper-v -Prefix rhpv_

However, when I do a get-help rhpv_ I do not show any commands that contain that prefix.

If I do

PS C:\> get-vmhost -ComputerName SERVER

Name   LogicalProcessorCount MemoryCapacity(M) VirtualMachineMigrationEnabled
----   --------------------- ----------------- ------------------------------
SERVER 12                    16375.08984375    True

I can see I have commands. However, if I go to type get-vmh and tab I get

PS C:\> tmp_1d1czacs.mzd\Get-VMHost computername SERVER
tmp_1d1czacs.mzd\Get-VMHost : The term 'tmp_1d1czacs.mzd\Get-VMHost' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1
+ tmp_1d1czacs.mzd\Get-VMHost computername SERVER
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (tmp_1d1czacs.mzd\Get-VMHost:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Just curious if I am using the import modules from a remote host correct or if this is how PS works.

$s = New-PSSession -ComputerName Server01
Invoke-Command -Session $s {Import-Module Hyper-V}
Import-PSSession -Session $s -Module Hyper-V

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM