0% found this document useful (0 votes)
9 views8 pages

Classwork 5

The document provides instructions for enabling and using PowerShell remoting on Windows systems, specifically detailing commands like Enable-PSRemoting, Invoke-Command, and New-PSSession. It includes exercises for practicing these commands, such as retrieving event logs and managing remote sessions. Additionally, it explains the behavior of PowerShell when sessions are closed and the implications of implicit remoting.

Uploaded by

Kevin Hoag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views8 pages

Classwork 5

The document provides instructions for enabling and using PowerShell remoting on Windows systems, specifically detailing commands like Enable-PSRemoting, Invoke-Command, and New-PSSession. It includes exercises for practicing these commands, such as retrieving event logs and managing remote sessions. Additionally, it explains the behavior of PowerShell when sessions are closed and the implications of implicit remoting.

Uploaded by

Kevin Hoag
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 8

Kevin Hoag

Classwork 5
Background
Remember that incoming remoting sessions are only enabled by default on Windows
Server 2012
R2. For other operating systems, you must run Enable-PSRemoting to enable
incoming connections
Kevin Hoag
Classwork 5
Syntax Review
Remember the following
 Invoke-Command can send a command, or the contents of a script file, to
one or more remote computers. You can specify computer names for ad
hoc sessions, or specify PSSession objects to use a persistent session.
 Enter-PSSession lets you interact with a single remote computer. You can
specify a computer name for an ad hoc session, or a single PSSession object
to use that persistent session.
 New-PSSession creates a new persistent session on a remote computer.
The resulting session object is often stored in a variable for easier access.
 Import-Module can be used to import commands from a remote module.
You must specify an existing PSSession object to import from.
 Enable-PSRemoting can enable remoting on the local computer. Add
–SkipNetworkProfileCheck if your computer includes network interfaces
marked as “public.” This is often the case on computers where a
workstation virtualization product is installed.

PLEASE SCREENSHOT YOUR COMMANDS AND OUTPUT AS WELL


AS ANSWERING THE QUESTIONS FOR EACH QUESTION!
Exercises
1. Start by enabling remoting, if it is not already enabled, on all of your virtual
machines. If you only have one virtual machine, or are using your host
computer, enable remoting on it.

For the following exercises, provide a comma separated list of your computer
and/or virtual machine names. Use localhost to access your local computer via
remoting.

2. Using Invoke-Command, send the following command to one or more


computers:
Get-EventLog –LogName Security –Newest 100
Kevin Hoag
Classwork 5

3. Use New-PSSession to create a session to a single remote computer. Save the


session object in the variable $remote.

4. Use Get-Module, passing it the session in $remote, to list the available


modules on the remote computer. You may need to read the help on Get-
Module to find the correct parameters for this.
Kevin Hoag
Classwork 5

Tasks 5 and 6 may cause an error on some systems. Read the


error message, diagnose the cause, and see if you can resolve
it. If you cannot, ask for help.

5. Use Import-Module, passing in the session in $remote, to import the


NetAdapter module from the remote computer. Prefix the imported
commands with “Remote”. You may need to read the help on Import-Module
to find the correct parameters for this.
Kevin Hoag
Classwork 5

6. Run the Get-NetAdapter command from the remote computer. The


command name should be Get-RemoteNetAdapter if you completed the
previous tasks correctly.

7. Use Get-PSSession and Remove-PSSession to close all open PSSessions on


your computer. After doing so, try running Get-RemoteNetAdapter again.
What happens? Why?
Kevin Hoag
Classwork 5

When you run a command that was imported from a remote session (like Get-
RemoteNetAdapter), and the session it was imported from no longer exists, PowerShell will
attempt to create a new session to the original computer and implicitly reimport the
command. This is a feature known as implicit remoting.

8. Use Enter-PSSession and a computer name to interactively remote to a


single computer (it can be localhost). Notice the change in the PowerShell
prompt. Try to run Enter-PSSession again. What happens? Why? Run Exit to
close the session.
Kevin Hoag
Classwork 5

If you try running Enter-PSSession again while in a PSSession, you'll get an error. This is
because you can't enter into another PSSession from within an existing one.
Kevin Hoag
Classwork 5

You might also like