Execute Remote Commands

Now that you have your local and remote computers configured for Windows PowerShell Remoting, we can examine the different techniques for executing commands against the remote computer.

When it comes to executing commands against the remote computer, there are three different options available to us:

  • Execute commands one at a time using the Invoke-Command cmdlet.
  • Connect to a remote session and operate within that session using the Enter-PSSession cmdlet.
  • Import a remote session and operate on that session as though working locally using the Import-PSSession cmdlet.

Each of these three approaches has its own pros and cons. However, for reasons that will be made clear later in this chapter, we prefer the Enter-PSSession ...

Get Automating Microsoft® SharePoint® 2010 Administration with Windows PowerShell® 2.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.