Admin Power

Chapter 10 of 18

Chapter 10: Run Commands on Other Computers

This chapter is about remoting, which means running commands on another computer from your own keyboard. You will learn why this matters, because one admin often looks after many computers, and visiting each one in person would take forever. You will practise sending a single command to one or more computers, and you will also practise opening a live session on one computer so you can explore it step by step. You will learn what changes when results travel back to you, and why you should always check which computer you are working on. By the end, you will be able to run remote work with more confidence, and to spot the simple setup problems that stop remoting from working.

2 lessons 3 learning objectives 1 diagram 4 related commands

Topics at a glance: Invoke-Command: run a command remotely, Enter-PSSession: an interactive remote session.

Where this chapter fits

This chapter comes after Chapter 9: Make Scripts Decide and Repeat in the journey, so ideas from that chapter will feel familiar here.

After this chapter comes Chapter 11: Manage People, Computers, and Names.

Learning objectives

By the end of this chapter, you will be able to:

  • Explain remoting and WinRM in plain words
  • Run a command on a remote computer with Invoke-Command
  • Open an interactive remote session with Enter-PSSession

Lessons in this chapter

Work through the lessons in order. Each lesson page has explanations, examples, common mistakes, and a knowledge check.

  1. Lesson 1: Invoke-Command: run a command remotely

    Invoke-Command sends a script block to one or more computers, runs it there, and returns the results as objects. The work happens on the remote computer, not yours.

    3 things to learn in this lesson

  2. Lesson 2: Enter-PSSession: an interactive remote session

    Enter-PSSession opens an interactive session on a remote computer. Your prompt changes, and every command you type runs there until you exit.

    3 things to learn in this lesson

Diagrams in this chapter

These diagrams come from lessons in this chapter. Tap a stage in a diagram to see what it does.

Remoting (from the lesson: Invoke-Command: run a command remotely)

Your computerInvoke-CommandWinRMresults returnRemote computerruns the commandThe command runs remotely. Only the results come back.

Choose a stage above to see what it does.

Related command references

These command pages are linked to lessons in this chapter. Each command page has its syntax, parameters, and examples.

  • Test-WSMan

    Tests whether WinRM answers on a computer, for remoting.

    From the lesson: Invoke-Command: run a command remotely

  • Invoke-Command

    Runs a script block on remote computers and returns the results.

    From the lesson: Invoke-Command: run a command remotely

  • Enter-PSSession

    Opens an interactive session on a remote computer.

    From the lesson: Enter-PSSession: an interactive remote session

  • Get-ComputerInfo

    Shows facts about the computer, such as Windows version.

    From the lesson: Enter-PSSession: an interactive remote session

Tip: read the lesson first, then use the command page as a quick reference.