[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Powershell Remote With Remote Module

Posted on 2013-01-21
2
Medium Priority
?
749 Views
Last Modified: 2013-01-22
I have a server that I ran Enable-PSRemoting on successfully.  

I am able to run Enter-PSSession <computername> from my local workstation and successfully connect.

I need to somehow import a module from the remote server into the session I am using and be able to use cmdlets from that module.  I don't want to have to import the module locally.

Is that even possible?
0
Comment
Question by:jonathanbyers
2 Comments
 
LVL 40

Accepted Solution

by:
Subsun earned 1400 total points
ID: 38803515
Try this..
$Session = New-PSSession "ServerName"
Invoke-Command -Session $Session {Import-Module RemoteDesktopServices}
Invoke-Command -Session $Session {Get-PSDrive}

Open in new window

0
 
LVL 71

Assisted Solution

by:Qlemo
Qlemo earned 600 total points
ID: 38804398
You can also combine the complete script into a single block, which is usually more straight-forward (I'm using the same lines as Subsun as an example):
$Session = New-PSSession "ServerName"
Invoke-Command -Session $Session {
  Import-Module RemoteDesktopServices
  Get-PSDrive
}

Open in new window

0

Featured Post

Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Transferring FSMO roles is done when an admin wants to split roles between certain Domain Controllers or the Domain Controller holding the Roles has been forcefully demoted using dcpromo / forceremoval
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
The viewer will learn how to successfully create a multiboot device using the SARDU utility on Windows 7. Start the SARDU utility: Change the image directory to wherever you store your ISOs, this will prevent you from having 2 copies of an ISO wit…
Suggested Courses

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question