Powershell Remoting: using imported module cmdlets in a remote pssession

前端 未结 7 2108
我在风中等你
我在风中等你 2021-02-05 12:34

Is there a way to use modules that were imported in a local session in a remote session? I looked at import-pssession, but I don\'t know how to get the local session. Here\'s a

相关标签:
7条回答
  • 2021-02-05 13:08

    I would suggest something like:

    $rs = New-PSSession -ComputerName "RemoteComputer"
    Invoke-Command -Session $rs -scriptblock {import-module ActiveDirectory}
    Import-PSSession -Session $rs -Module ActiveDirectory
    

    Since then, you can use ActiveDirectory cmdlets in your session.

    Hope this helps.

    0 讨论(0)
提交回复
热议问题