All posts tagged: PowerShell Remoting

Executing script existing only on a remote system using Invoke-Command

This is more of a personal note and may sound trivial to many of you out there. But just wanted to make sure I share it here. A while back, in my remoting series, I wrote about executing commands / scripts on a remote machine using Invoke-Command cmdlet. Talking specifically about scripts, you can use -FilePath parameter to execute scripts on a remote machine.

Note that the script you provide as a value to -FilePath must exist on the local machine or at a place accessible to the local machine. So, what if you want to run a script that exists only on the remote server? You can use script block for that. Invoke-Command -ComputerName SP2010-WFE -scriptBlock { C:\scripts\Test.PS1 } This way, you can execute the script present on a remote machine but not on the local system. I’ve published a free book on PowerShell 2.0 remoting. You can download it at:

eBook: Layman’s guide to PowerShell 2.0 remoting

If are you a regular visitor to this blog, you may be aware of my PowerShell remoting series of blog articles. Traffic to this blog increased by almost 80% ever since I started the remoting series. This set of articles appear on the first page of Internet search almost all the time. The idea behind starting the remoting series was to develop the content in to an eBook at the end. I have been sitting on it for while and just got a chance to complete it after a few late night efforts.This eBook has more content than the remoting blog posts. This kinda concludes the remoting series. There are a few things I have not discussed including fan-in remoting. I will add those things as separate chapters, if required. You can download the eBook here This eBook got an update from the initial release. Here are the additions in the update. Chapter 2 Enable remoting for only a specific network adapter Remoting in an Enterprise Chapter 3 Run script files on remote computers Chapter 9 …

Enabling PowerShell remoting for only a specified set of IP addresses

I’ve published a free book on PowerShell 2.0 remoting. You can download it at: I wasn’t so sure about the post title. But read on to understand what I really meant. 🙂 When you enable remoting on a computer using Enable-PSRemoting cmdlet, an http listener will be created to listen for remoting requests on all IP addresses on the local computer. This may not be a great security practice in an enterprise. For example, you have an Internet facing server with two network connections. One – obviously – is the Internet connection and a second one connecting to your internal network. You don’t need remoting be enabled on the network adapter connected Internet. But, since you used Enable-PSRemoting cmdlet, remoting will be enabled and there is a WinRM listener on the Internet facing network too. So, how do we disable remoting on the Internet facing adapter? Enable-PSRemoting is a comprehensive cmdlet that does lot of things for you in one shot. This is also the recommended way to enable remoting. So, if we need to …

Remote file explorer using PowerShell remoting and Windows forms

Last week, I released the remote file explorer powerpack for PowerGUI. The concept of this powerpack is quite simple. We use PowerShell remoting to access the PS drives of a remote machine and then use the same remoting channel to transfer files between computers. I’ve published a free book on PowerShell 2.0 remoting. You can download it at: So, here is the first release of this forms based script. I have put this on CodePlex for better visibility and availability. This will also let me use the version control features of CodePlex. I am no expert in developing GUI applications and there will be some inefficient code. Do let me know when you find some thing like. I will fix it as soon as possible. The project is available at http://psremoteexplorer.codeplex.com/ and the latest release is http://psremoteexplorer.codeplex.com/releases/view/40933. Here is how the initial release looks As shown in the above screenshot, I have used TreeView control for the computer listing and then a DataGrid for listing the files. Requirements 1. PowerShell 2.0 2. pModem 0.5 or …

PowerShell 2.0 remoting guide: Part 12 – Using CredSSP for multi-hop authentication

I’ve published a free book on PowerShell 2.0 remoting. You can download it at: In this part of the remoting series, we look at how CredSSP can be used for multi-hop authentication in PowerShell remoting. CredSSP and multi-hop support are not features of PowerShell 2.0 or PowerShell remoting, per se. Credential Security Service Provider (CredSSP) is a new security service provider that enables an application to delegate the user’s credentials from the client to the target server. Multi-hop support in Windows Remote Management uses CredSSP for authentication. Since PowerShell 2.0 remoting is built on top of WinRM, we can use CredSSP to perform multi-hop authentication. So, what is multi-hop authentication? Well, let us look at an example to understand what is multi-hop authentication. Imagine a group of computers as shown here and you establish a remoting session from computer A (client) to computer B (server) and then from computer B, you try to create a file in a file share on computer C. CredSSP example Now, within the remoting session to computer B, we want to execute a command — as …

PowerShell 2.0 remoting guide: Part 11 – Interpreting, formatting and displaying remote output

I’ve published a free book on PowerShell 2.0 remoting. You can download it at: In this part of the remoting series, we look at remoting output. This includes how the output is transferred from remote computer to local, how it is displayed and how we can format this output based on a need. We already discussed various methods to execute commands (part4, part 5 and part 6) on a remote computer. In this post, for the sake of our discussion of remoting output, I will use only Invoke-Command method to execute remote commands. However, I will point out the differences as required. Note: Most of this does not apply within an interactive remoting session The concepts of remoting output are explained in a TechNet article at http://technet.microsoft.com/en-us/library/dd347582.aspx. I am going to put some story around this to help you understand the concepts well. First, let us start with an obvious difference in the output received from a remote session. If you use Invoke-Command to run Get-PSDrive, you see something like this. You can see an additional …

PowerShell 2.0 remoting guide: Part 10 – Restricting available commands using custom session configuration

Update: This post has been updated to provide accurate details around the subject. Old content has been removed. I’ve published a free book on PowerShell 2.0 remoting. You can download it at: “With great power comes great responsibility”, said uncle Ben. But some people don’t just understand that. That is when you have to rip-off their powers. Similarly, the default PS Session configuration allows full access to PowerShell language, cmdlets, scripts and everything available to PowerShell. Of course, you need to authenticate as a local administrator or should have execute permission to invoke the session. Running a few cmdlets such as Stop-Service or Restart-Computer can be quite dangerous on a production server. This is where a custom session configuration can help provide role based access to remote host using PowerShell remoting. We touched upon creating custom session configuration in part 9 of this PowerShell remoting series. In this part, I will discuss how we can extend the concept of custom session configuration to restrict available commands and PowerShell language in a remote session. I will go striaght …

PowerShell 2.0 remoting guide: Part 9 – Session configurations and creating custom configurations

I’ve published a free book on PowerShell 2.0 remoting. You can download it at: In part2 of this series on PowerShell remoting we quickly looked at various cmdlets that form part of overall remoting infrastructure. The list there included cmdlets related to PS Session configuration. Now that we have gone through the basics of remoting, it is time for us to dig in to these additional cmdlets and explore what they really do. So, in this part, we will look at all the PS session configurtion cmdlets, discuss how to create custom PS Session configurations and the need for it. Let us dive in to this now. What is PS session configuration? A session configuration can be used to define who can create a Windows PowerShell sesion on the local computer, what level of access — to cmdlets, scripts and PowerShell language — they have on the local computer, etc. When you enable PowerShell remoting using Enable-PSRemoting, you will see a final step performing Microsoft.PowerShell and Microsoft.PowerShell32 (on x64 systems) session configuration registrations. These default session configurations are used …