SlideShare a Scribd company logo
Taking Advantage of Microsoft
PowerShell
Presented by Jared Thibodeau
© Global Knowledge Training LLC. All rights reserved. Page 2
Presenter
Jared Thibodeau
Microsoft Operations Instructor at Global Knowledge
• bilingual, cross-certified instructor with hands-on
implementation experience and over
• 20 years of IT consulting and teaching experience
• Windows NT, Server 2000-2016, Windows XP-10, SharePoint
2007-2016, System Center, SCCM, SCOM, VMware and
Hyper-V Virtualization, Cloud and many others.
Topic 1
What you can administer with PowerShell
© Global Knowledge Training LLC. All rights reserved. Page 4
Windows PowerShell overview
• Introduced in 2006
• Both a CLI and scripting language
• Commands include:
• Cmdlets (pronounced command-lets)
• Functions
• Filters
• Workflows
• Microsoft server applications provide application-
specific cmdlets
• Now open-source and supports Linux and macOS
© Global Knowledge Training LLC. All rights reserved. Page 5
Windows PowerShell vs. operating system
• Windows PowerShell ships with specific core,
native functionality
• Most of its use, however, comes from
extensions―additional commands that extend the
capabilities of Windows PowerShell
• Extensions are designed to work with a specific
version of Windows PowerShell, but they do not
ship with Windows PowerShell itself
• Instead, extensions are provided as part of an
operating system or a specific product version
© Global Knowledge Training LLC. All rights reserved. Page 6
Two host applications
• Console
• Basic command-line interface
• Maximum support for PowerShell features
• Minimal editing capabilities
• ISE
• Script editor and console combination
• Some Windows PowerShell features not supported
• Rich editing capabilities
• Third-party hosting applications/editors
• Varying features and pricing
© Global Knowledge Training LLC. All rights reserved. Page 7
Working in mixed-version environments
• Many organizations must operate environments
that contain more than one version of Windows
PowerShell
• Use $PSVersionTable to determine the version of
Windows PowerShell on a computer
© Global Knowledge Training LLC. All rights reserved. Page 8
Precautions when opening Windows PowerShell
• 64-bit operating systems include 64-bit and 32-bit
versions
• 32-bit versions carry (x86) designation on icon and window title bar
• Be certain you are opening the appropriate version for the task at
hand
• Usually, open the 64-bit version if it is available
• Ensure that the window title bar displays Administrator if
you need administrative privileges in Windows PowerShell
• When UAC is enabled, you must right-click the application icon to
run as Administrator
• Always verify the window title bar contents when opening Windows
PowerShell
© Global Knowledge Training LLC. All rights reserved. Page 9
Configuring the ISE
• Two panes: script and console
• One-pane and two-pane view options
• Command Add-on displays available commands
• Customization of font style, size, and color
• Customization of screen color
• Bundling of color selections into themes
• Additional features include snippets, add-ins, and
debugging
Topic 2
How to find and execute PowerShell
commands
© Global Knowledge Training LLC. All rights reserved. Page 11
Lesson 2: Understanding command syntax
Cmdlet structure
Parameters
Tab completion
Using Get-Help
Demonstration: Viewing help
Interpreting the help syntax
Updating help
About files
Demonstration: Using About files
© Global Knowledge Training LLC. All rights reserved. Page 12
Cmdlet structure
• Verb is the action the cmdlet performs:
• Get
• Set
• New
• Add
• Remove
• Noun is the resource the cmdlet affects:
• Service
• Process
• Prefixes used to group related nouns:
• AD, SP, and AzureAD
© Global Knowledge Training LLC. All rights reserved. Page 13
Parameters
• Parameters modify the action of a cmdlet
• Names are entered starting with a dash (-)
• Parameters can be optional or required
• You will receive prompts for required parameters, if needed
• Some accept multiple values, separated by commas
• Parameter name is optional for positional parameters
© Global Knowledge Training LLC. All rights reserved. Page 14
Tab completion
• Allows you to enter cmdlet, parameter, variable, and path
names more quickly and accurately
• Helps you to discover cmdlets and parameters
• Supports the use of wildcards
© Global Knowledge Training LLC. All rights reserved. Page 15
Using Get-Help
• Displays Windows PowerShell help content
• You provide a cmdlet name to display help for a
cmdlet
• Supports wildcards
• Parameters include:
• -Examples
• -Full
• -Online
• -ShowWindow
• -Parameter ParameterName
© Global Knowledge Training LLC. All rights reserved. Page 16
Demonstration: Viewing help
In this demonstration, you will see how to use
various options of the help system
© Global Knowledge Training LLC. All rights reserved. Page 17
Interpreting the help syntax
Parameter set Mandatory parameter
Positional parameter Optional parameter
© Global Knowledge Training LLC. All rights reserved. Page 18
About files
• Provide documentation for global shell techniques,
concepts, and features
• Start with about_
• View list by running Get-Help about*
• You will need to read many of these files to complete
several upcoming lab exercises
© Global Knowledge Training LLC. All rights reserved. Page 19
Demonstration: Using About files
In this demonstration, you will see how to use the
About help file topics
© Global Knowledge Training LLC. All rights reserved. Page 20
Lesson 3: Finding commands
What are modules?
Demonstration: Viewing modules
Finding cmdlets
Demonstration: Searching for cmdlets
What are aliases?
Demonstration: Using aliases
Using Show-Command
© Global Knowledge Training LLC. All rights reserved. Page 21
What are modules?
• Modules:
• Are containers for related cmdlets
• Are provided as part of management tools for various software
packages
• Must be loaded into current session
• Windows PowerShell version 3.0 and newer support
autoloading
• Autoloading requires Windows Server 2012/ Windows 8 or
newer
© Global Knowledge Training LLC. All rights reserved. Page 22
Demonstration: Viewing modules
In this demonstration, you will see:
• How to find installed modules
• How autoloading and manual loading of modules
work
© Global Knowledge Training LLC. All rights reserved. Page 23
Finding cmdlets
• Use Get-Command and Get-Help, both of which support wildcards
• Use –Noun, –Verb, and –Module parameters with
Get-Command
• Get-Help can also search the content of help files if no match is found
when searching command names
• Use the PowerShellGet module to find modules and commands from
the PowerShell Gallery
© Global Knowledge Training LLC. All rights reserved. Page 24
Demonstration: Searching for cmdlets
In this demonstration, you will see how to use
several techniques to discover new cmdlets
© Global Knowledge Training LLC. All rights reserved. Page 25
What are aliases?
• Familiar batch commands include:
• Dir
• Cd
• Mkdir
• Type
• These are really aliases to Windows PowerShell commands
• External commands such as ping.exe and ipconfig.exe all work as
usual
• Windows PowerShell commands often have a different syntax, even
if accessed by an alias that matches an older command name
© Global Knowledge Training LLC. All rights reserved. Page 26
Demonstration: Using aliases
In this demonstration, you will see how to:
• Find an alias for a cmdlet
• Find a cmdlet based on an alias you already know
• Create an alias
© Global Knowledge Training LLC. All rights reserved. Page 27
Using Show-Command
Topic 3
How to format information and combine
multiple PowerShell commands
© Global Knowledge Training LLC. All rights reserved. Page 29
Module Overview
Understanding the pipeline
Selecting, sorting, and measuring objects
Filtering objects out of the pipeline
Enumerating objects in the pipeline
Sending pipeline data as output
© Global Knowledge Training LLC. All rights reserved. Page 30
Lesson 1: Understanding the pipeline
What is the pipeline?
Pipeline output
Discovering object members
Demonstration: Viewing object members
Formatting pipeline output
Demonstration: Formatting pipeline output
© Global Knowledge Training LLC. All rights reserved. Page 31
What is the pipeline?
• Windows PowerShell runs commands in a pipeline
• Each console command line is a pipeline
• Commands separated by a pipe character (|)
• Commands execute from left to right
• Output of each command is piped (passed) to the next
• The output of the last command in the pipeline is what
appears on your screen
• Piped commands typically follow the pattern Get |Set, Get
| Where, or Select | Set
© Global Knowledge Training LLC. All rights reserved. Page 32
Pipeline output
• Windows PowerShell commands produce objects
as their output
• An object is like a table of data in memory
• Allows the Get | Set pattern to work
Name Status DisplayName
WinRM Running Windows
Remote
Management
VDS Running Virtual Disk
Property
Object
Collection
© Global Knowledge Training LLC. All rights reserved. Page 33
Discovering object members
• Object members include:
• Properties
• Methods
• Events
• Run a command that produces an object, and pipe that
object to Get-Member to see a list of members
• Get-Member is a discovery tool, similar to Help, that can
help you learn to use the shell
© Global Knowledge Training LLC. All rights reserved. Page 34
Demonstration: Viewing object members
In this demonstration, you will see how to run
commands in the pipeline and how to use Get-
Member
© Global Knowledge Training LLC. All rights reserved. Page 35
Formatting pipeline output
• Use the following cmdlets to format pipeline output:
• Format-List
• Format-Table
• Format-Wide
• The -Property parameter:
• Is common to all formatting cmdlets
• Filters output to specified property names
• Can only specify properties that were passed to the formatting
command
© Global Knowledge Training LLC. All rights reserved. Page 36
Demonstration: Formatting pipeline output
In this demonstration, you will see how to format
pipeline output
© Global Knowledge Training LLC. All rights reserved. Page 37
Creating calculated properties
• Calculated (custom) properties let you choose the output
label and contents
• Each calculated property works like a single regular property
in the property list accepted by Select-Object
• Create calculated properties by using a specific syntax:
• Label defines the property name
• Expression defines the property contents
• Within the expression, $PSItem (or $_) refers to the piped-in object
© Global Knowledge Training LLC. All rights reserved. Page 38
Creating calculated properties
@{
n='VirtualMemory';
e={ $PSItem.VM }
}
Hash table
Label key Label string
value
Expression key Expression
script block
Semicolon
Calculated property hash table
© Global Knowledge Training LLC. All rights reserved. Page 39
Demonstration: Creating calculated properties
In this demonstration, you will see how to use
Select-Object to create calculated properties. You
will then see how those calculated properties
behave like regular properties.
© Global Knowledge Training LLC. All rights reserved. Page 40
Lesson 5: Sending pipeline data as output
Writing output to a file
Converting output to CSV
Converting output to XML
Converting output to JSON
Converting output to HTML
Demonstration: Exporting data
Additional output options
© Global Knowledge Training LLC. All rights reserved. Page 41
Writing output to a file
• Out-File writes whatever is in the pipeline to a text file
• The > and >> redirection operators are also supported
• The text file is formatted exactly the same as the data would have
appeared on the screen―no conversion to another form occurs
• Unless the data has been converted to another form, the resulting text
file is usually suitable for viewing only by a person
• As you start to build more complex commands, you need to keep
track of what the pipeline contains at each step
© Global Knowledge Training LLC. All rights reserved. Page 42
Converting output to CSV
• The commands are:
• ConvertTo-CSV
• Export-CSV
• The commands send:
• Properties as headers
• No type information
• You can easily open large CSV files in Excel
© Global Knowledge Training LLC. All rights reserved. Page 43
Converting output to XML
• ConvertTo-CliXml
• Export-CliXml
• Portable data format
• Multivalue properties become individual entries
© Global Knowledge Training LLC. All rights reserved. Page 44
Converting output to JSON
• The command is
• ConvertTo-JSON
• The advantages are:
• Compactness
• Ease of use, especially with JavaScript
• A format like a hash table
© Global Knowledge Training LLC. All rights reserved. Page 45
Converting output to HTML
• The command is ConvertTo-HTML
• The command creates a table or list in HTML
• You must pipe the output to a file
• The parameters include:
• -Head
• -Title
• -PreContent
• -Postcontent
© Global Knowledge Training LLC. All rights reserved. Page 46
Demonstration: Exporting data
In this demonstration, you will see different ways to
convert and export data
© Global Knowledge Training LLC. All rights reserved. Page 47
Additional output options
• Out-Host allows more control of on-screen output
• Out-Printer sends output to a printer
• Out-GridView creates an interactive, spreadsheet-like
view of the data
Topic 4
How to perform actions on remote
computers using PowerShell
© Global Knowledge Training LLC. All rights reserved. Page 49
Module Overview
Using basic Windows PowerShell remoting
Using advanced Windows PowerShell remoting techniques
Using PSSessions
© Global Knowledge Training LLC. All rights reserved. Page 50
Lesson 1: Using basic Windows PowerShell remoting
Remoting overview and architecture
Remoting vs. remote connectivity
Remoting security
Enabling remoting
Using remoting: one-to-one
Using remoting: one-to-many
Demonstration: Enabling and using remoting
Remoting output vs. local output
© Global Knowledge Training LLC. All rights reserved. Page 51
Remoting overview and architecture
Remoting:
• Uses WS-MAN protocol, using HTTP (by default) or HTTPS
• Is implemented by WinRM service
• Is enabled by default on Windows Server 2016; available on any
computer running Windows PowerShell 2.0 or greater
• Is not enabled on any client operating system
• Must be enabled on any computer that will receive incoming
connections
© Global Knowledge Training LLC. All rights reserved. Page 52
Remoting vs. remote connectivity
• Remoting is the name of a specific feature that utilizes a specific
service and protocol
• When used in Windows PowerShell, use the term Windows
PowerShell remoting
• It applies to a relatively small subset of commands that can
communicate with remote computers
• A command with a –ComputerName parameter does not
necessarily mean it uses remoting
• Nonremoting commands use their own protocols:
• RPCs, which include WMI
• Remote Registry Service (for example, Get-Process)
© Global Knowledge Training LLC. All rights reserved. Page 53
Remoting security
• Remoting is security transparent; you can perform only those
tasks that your credentials allow
• Mutual authentication helps prevent delegation of credentials
to spoofed or impersonated computers:
• It works in domain environments by default
• It can use SSL in lieu of domain credentials
• It can be disabled through the TrustedHosts list
© Global Knowledge Training LLC. All rights reserved. Page 54
Remoting security
Remoting privacy:
• Channel-level encryption is provided only with HTTPS connections
• Application-level encryption is provided with all connections
• Credentials are transmitted in clear text only with the Basic
authentication protocol when HTTPS is not in use (for example, to
a nondomain computer on TrustedHosts list)
• You cannot use Basic authentication unless you enable
unencrypted traffic in the client configuration
© Global Knowledge Training LLC. All rights reserved. Page 55
Enabling remoting
• To enable Windows PowerShell remoting manually, run Enable-
PSRemoting as an Administrator
• To enable Windows PowerShell remoting centrally, configure a
GPO
• There are restrictions on client computers where a network
connection is set to Public
• Windows Server 2012 and later enable Windows PowerShell
remoting by default; no further steps are needed
© Global Knowledge Training LLC. All rights reserved. Page 56
Using remoting: one-to-one
One-to-one Windows PowerShell remoting is similar in
concept to SSH, although different in actual operation:
1. Start with
Enter-PSSession –ComputerName name
2. The Windows PowerShell prompt changes to indicate the
connected computer
3. Exit with Exit-PSSession
© Global Knowledge Training LLC. All rights reserved. Page 57
Using remoting: one-to-many
• Invoke-Command can send a command or script to one or
more remote computers in parallel
• Results include a PSComputerName property that indicate
the computer each result came from
• Considerations include:
• Throttling
• Passing data to remote computers
• Persistence
• Ways to specify computer names
© Global Knowledge Training LLC. All rights reserved. Page 58
Demonstration: Enabling and using remoting
In this demonstration, you will see how to enable
remoting on a client computer, and how to use
remoting in several basic scenarios
© Global Knowledge Training LLC. All rights reserved. Page 59
Remoting output vs. local output
• Results received through remoting are deserialized from XML
• As a result, they are not live objects and do not have
methods or events
• As a strategy, try to have as much processing as possible
occur on the remote computer, with only the final results
coming back to you through remoting
© Global Knowledge Training LLC. All rights reserved. Page 60
Lesson 2: Using advanced Windows PowerShell remoting
techniques
Common remoting options
Sending parameters to remote computers
Windows PowerShell scopes
Demonstration: Sending local variables to a remote computer
Multi-hop remoting
© Global Knowledge Training LLC. All rights reserved. Page 61
Common remoting options
• –Port
• –UseSSL
• –Credential
• –ConfigurationName
• –Authentication
• Additional options are available by creating a
PSSessionOption object, and then passing it to
–SessionOption
© Global Knowledge Training LLC. All rights reserved. Page 62
Sending parameters to remote computers
• You cannot use local variables in the Invoke-Command
script block
• You can pass data. However, you must use a specific
technique
• Pass local variables to the –ArgumentList parameter of
Invoke-Command; they will map to variables in a Param()
block inside the script block
© Global Knowledge Training LLC. All rights reserved. Page 63
Multi-hop remoting
1 2
© Global Knowledge Training LLC. All rights reserved. Page 64
Lesson 3: Using PSSessions
Persistent connections
Creating a PSSession
Using a PSSession
Demonstration: Using PSSessions
Disconnected sessions
Demonstration: Disconnected sessions
Implicit remoting
Demonstration: Implicit remoting
© Global Knowledge Training LLC. All rights reserved. Page 65
Persistent connections
• PSSessions:
• Represent a persistently running connection on the remote
computer
• Can execute multiple sequences of commands, be
disconnected, reconnected, and closed
• Numerous configuration parameters in the drive WSMan
control idle session time and maximum connections
© Global Knowledge Training LLC. All rights reserved. Page 66
Creating a PSSession
• Create sessions by using New-PSSession; the command
produces a reference to the PSSessions it creates
• Assign PSSessions to variables to make them easier to
refer to later
© Global Knowledge Training LLC. All rights reserved. Page 67
Using a PSSession
• Pass a session object to the –Session parameter of Enter-
PSSession to interactively enter that session
• Alternatively, pass session object(s) to the
–Session parameter of Invoke-Command to
run a command against those PSSessions
• The PSSessions remain open and connected after you are
finished, leaving them ready for additional use
© Global Knowledge Training LLC. All rights reserved. Page 68
Demonstration: Using PSSessions
In this demonstration, you will see how to create
and manage PSSessions
© Global Knowledge Training LLC. All rights reserved. Page 69
Disconnected sessions
• Disconnect-PSSession disconnects from a PSSession while
leaving Windows PowerShell running:
• Does not happen automatically when you close the host application
• Get-PSSession –ComputerName displays a list of your
PSSessions on the specified computer:
• You cannot see other users’ PSSessions
• Connect-PSSession reconnects a PSSession, making it
available for use
© Global Knowledge Training LLC. All rights reserved. Page 70
Demonstration: Disconnected sessions
In this demonstration, you will see how to:
• Create a PSSession
• Disconnect a PSSession
• Display PSSessions
• Reconnect a PSSession
© Global Knowledge Training LLC. All rights reserved. Page 71
Implicit remoting
• Imports commands from a remote computer to the local
one:
• Imported commands still run on the remote computer
through an established remoting session
• Lets you utilize commands without needing to install them
• Help is also drawn from the remote computer
© Global Knowledge Training LLC. All rights reserved. Page 72
Demonstration: Implicit remoting
In this demonstration, you will see how to use
implicit remoting to import and use a module from
a remote computer
© Global Knowledge Training LLC. All rights reserved. Page 73
Courses
Automating
Administration
with Windows
PowerShell
Advanced
Automated
Administration
Windows
PowerShell
Scripting and
Toolmaking
© Global Knowledge Training LLC. All rights reserved. Page 74
Learning More
GlobalKnowledge.com
For additional on-demand and live webinars,
white papers, courses, special offers and
more, visit us at…

More Related Content

What's hot (20)

PPTX
Microsoft Offical Course 20410C_10
gameaxt
 
PDF
Active Directory Delegation - By @rebootuser
camsec
 
PDF
Unleashing the Power: A Lap Around PowerShell 3.0
Sarah Dutkiewicz
 
PPTX
CamSec Sept 2016 - Tricks to improve web app excel export attacks
Jerome Smith
 
PPTX
An Introduction To Model  View  Controller In XPages
Ulrich Krause
 
PPTX
Microsoft Offical Course 20410C_04
gameaxt
 
PPTX
Microsoft Offical Course 20410C_09
gameaxt
 
PDF
60 Admin Tips
Gabriella Davis
 
PDF
XPages Blast - Lotusphere 2012
Tim Clark
 
PPTX
Best MCSA - SQL SERVER 2012 Training Institute in Delhi
Information Technology
 
PPTX
Microsoft Offical Course 20410C_12
gameaxt
 
PDF
CO_Scenario_InfoDelivTr_FINAL ENGLISH
Leonardo Sepulcri
 
PDF
AtoM feature development
Artefactual Systems - AtoM
 
PPTX
Microsoft Offical Course 20410C_13
gameaxt
 
PPT
Supporting SQLserver
Concentrated Technology
 
PDF
Zend_Cache: how to improve the performance of PHP applications
Enrico Zimuel
 
PDF
June OpenNTF Webinar - Domino V12 Certification Manager
Howard Greenberg
 
PDF
Developing High Performance and Scalable ColdFusion Application Using Terraco...
ColdFusionConference
 
PDF
Face Off Domino vs Exchange On Premises
Gabriella Davis
 
PPTX
MCSA 70-412 Chapter 03
Computer Networking
 
Microsoft Offical Course 20410C_10
gameaxt
 
Active Directory Delegation - By @rebootuser
camsec
 
Unleashing the Power: A Lap Around PowerShell 3.0
Sarah Dutkiewicz
 
CamSec Sept 2016 - Tricks to improve web app excel export attacks
Jerome Smith
 
An Introduction To Model  View  Controller In XPages
Ulrich Krause
 
Microsoft Offical Course 20410C_04
gameaxt
 
Microsoft Offical Course 20410C_09
gameaxt
 
60 Admin Tips
Gabriella Davis
 
XPages Blast - Lotusphere 2012
Tim Clark
 
Best MCSA - SQL SERVER 2012 Training Institute in Delhi
Information Technology
 
Microsoft Offical Course 20410C_12
gameaxt
 
CO_Scenario_InfoDelivTr_FINAL ENGLISH
Leonardo Sepulcri
 
AtoM feature development
Artefactual Systems - AtoM
 
Microsoft Offical Course 20410C_13
gameaxt
 
Supporting SQLserver
Concentrated Technology
 
Zend_Cache: how to improve the performance of PHP applications
Enrico Zimuel
 
June OpenNTF Webinar - Domino V12 Certification Manager
Howard Greenberg
 
Developing High Performance and Scalable ColdFusion Application Using Terraco...
ColdFusionConference
 
Face Off Domino vs Exchange On Premises
Gabriella Davis
 
MCSA 70-412 Chapter 03
Computer Networking
 

Similar to Taking Advantage of Microsoft PowerShell (20)

PPTX
PowerShell-1
Saravanan G
 
PPT
No-script PowerShell v2
Concentrated Technology
 
PPTX
02Introduction to Power Shell Win Server all in one.pptx
edget1
 
PDF
Windows Powershell Step By Step 3rd Edition Wilson Ed
forsenqenan
 
PDF
Windows PowerShell Step by Step 3rd Edition Wilson
phelpskwasia36
 
PPTX
Power Shell for System Admins - By Kaustubh
Kaustubh Kumar
 
PDF
Sql Server & PowerShell
Aaron Shilo
 
PPT
PowerShell Core Skills (TechMentor Fall 2011)
Concentrated Technology
 
PPTX
Introduction-to-PowerShell-azure-Syntax.pptx
MahmoudElmahdy32
 
PDF
Windows Powershell En
jason hu 金良胡
 
PPTX
PowerShell 101
Thomas Lee
 
PPTX
Power shell training
David Brabant
 
PPTX
PowerShell 101
Thomas Lee
 
PPTX
2016 spice world_london_breakout
Thomas Lee
 
PDF
PowerShell 101 Learning powershell with a ppw
alfedimu
 
PDF
PowerShell in Depth An administrator s guide Don Jones
lekwalakha3p
 
PDF
Mastering power shell - Windows
Ariel Devulsky
 
PDF
Mastering PowerShell
Fahad Noaman
 
PPTX
2014 SpiceWorld London Breakout
Thomas Lee
 
PPTX
Powershell Demo Presentation
Avik Bhattacharyya
 
PowerShell-1
Saravanan G
 
No-script PowerShell v2
Concentrated Technology
 
02Introduction to Power Shell Win Server all in one.pptx
edget1
 
Windows Powershell Step By Step 3rd Edition Wilson Ed
forsenqenan
 
Windows PowerShell Step by Step 3rd Edition Wilson
phelpskwasia36
 
Power Shell for System Admins - By Kaustubh
Kaustubh Kumar
 
Sql Server & PowerShell
Aaron Shilo
 
PowerShell Core Skills (TechMentor Fall 2011)
Concentrated Technology
 
Introduction-to-PowerShell-azure-Syntax.pptx
MahmoudElmahdy32
 
Windows Powershell En
jason hu 金良胡
 
PowerShell 101
Thomas Lee
 
Power shell training
David Brabant
 
PowerShell 101
Thomas Lee
 
2016 spice world_london_breakout
Thomas Lee
 
PowerShell 101 Learning powershell with a ppw
alfedimu
 
PowerShell in Depth An administrator s guide Don Jones
lekwalakha3p
 
Mastering power shell - Windows
Ariel Devulsky
 
Mastering PowerShell
Fahad Noaman
 
2014 SpiceWorld London Breakout
Thomas Lee
 
Powershell Demo Presentation
Avik Bhattacharyya
 
Ad

More from Global Knowledge Training (20)

PPTX
PAN-OS - Network Security/Prevention Everywhere
Global Knowledge Training
 
PPTX
The Basics of Computer Networking
Global Knowledge Training
 
PPTX
How To Troubleshoot Group Policy in Windows 10
Global Knowledge Training
 
PPTX
Accelerating with Ansible
Global Knowledge Training
 
PPTX
Why Pentesting is Vital to the Modern DoD Workforce
Global Knowledge Training
 
PPTX
How to Maximize Your Training Budget
Global Knowledge Training
 
PPTX
Develop Your Skills with Unlimited Access to Red Hat Online Learning
Global Knowledge Training
 
PPTX
Exploring the Upgrade from VMware vSphere: Install, Configure, Manage 6 5 to 6 7
Global Knowledge Training
 
PPTX
What’s Next For Your Azure Certification Journey
Global Knowledge Training
 
PPTX
Cisco's Intent-Based Networking and the Journey to Software Defined Networks
Global Knowledge Training
 
PPTX
How to Build a Winning Cybersecurity Team
Global Knowledge Training
 
PPTX
Why It’s Critical to Apply the Risk Management Framework to Your IT Moderniza...
Global Knowledge Training
 
PPTX
How to Build a Web Server with AWS Lambda
Global Knowledge Training
 
PPTX
The Essence of DevOps: What it Can Mean for You and Your Organization
Global Knowledge Training
 
PPTX
How to Migrate a Web App to AWS
Global Knowledge Training
 
PPTX
How to Make Agile Project Management Work in Your Organization
Global Knowledge Training
 
PPTX
What is Cryptojacking and How Can I Protect Myself?
Global Knowledge Training
 
PDF
How the Channel Can Break Down the Barriers to Cloud Success
Global Knowledge Training
 
PPTX
How to Avoid Cloud Migration Pitfalls
Global Knowledge Training
 
PPTX
Tackling 5 Taboo Topics in Cybersecurity People Management
Global Knowledge Training
 
PAN-OS - Network Security/Prevention Everywhere
Global Knowledge Training
 
The Basics of Computer Networking
Global Knowledge Training
 
How To Troubleshoot Group Policy in Windows 10
Global Knowledge Training
 
Accelerating with Ansible
Global Knowledge Training
 
Why Pentesting is Vital to the Modern DoD Workforce
Global Knowledge Training
 
How to Maximize Your Training Budget
Global Knowledge Training
 
Develop Your Skills with Unlimited Access to Red Hat Online Learning
Global Knowledge Training
 
Exploring the Upgrade from VMware vSphere: Install, Configure, Manage 6 5 to 6 7
Global Knowledge Training
 
What’s Next For Your Azure Certification Journey
Global Knowledge Training
 
Cisco's Intent-Based Networking and the Journey to Software Defined Networks
Global Knowledge Training
 
How to Build a Winning Cybersecurity Team
Global Knowledge Training
 
Why It’s Critical to Apply the Risk Management Framework to Your IT Moderniza...
Global Knowledge Training
 
How to Build a Web Server with AWS Lambda
Global Knowledge Training
 
The Essence of DevOps: What it Can Mean for You and Your Organization
Global Knowledge Training
 
How to Migrate a Web App to AWS
Global Knowledge Training
 
How to Make Agile Project Management Work in Your Organization
Global Knowledge Training
 
What is Cryptojacking and How Can I Protect Myself?
Global Knowledge Training
 
How the Channel Can Break Down the Barriers to Cloud Success
Global Knowledge Training
 
How to Avoid Cloud Migration Pitfalls
Global Knowledge Training
 
Tackling 5 Taboo Topics in Cybersecurity People Management
Global Knowledge Training
 
Ad

Recently uploaded (20)

PDF
Python basic programing language for automation
DanialHabibi2
 
PDF
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PPTX
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
PDF
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
PDF
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
PDF
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PPTX
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
PPTX
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
PDF
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
PDF
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
PPTX
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
PDF
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 
Python basic programing language for automation
DanialHabibi2
 
Agentic AI lifecycle for Enterprise Hyper-Automation
Debmalya Biswas
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
From Sci-Fi to Reality: Exploring AI Evolution
Svetlana Meissner
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
AI Penetration Testing Essentials: A Cybersecurity Guide for 2025
defencerabbit Team
 
Building Real-Time Digital Twins with IBM Maximo & ArcGIS Indoors
Safe Software
 
CIFDAQ Token Spotlight for 9th July 2025
CIFDAQ
 
"Beyond English: Navigating the Challenges of Building a Ukrainian-language R...
Fwdays
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Q2 FY26 Tableau User Group Leader Quarterly Call
lward7
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Reverse Engineering of Security Products: Developing an Advanced Microsoft De...
nwbxhhcyjv
 
"Autonomy of LLM Agents: Current State and Future Prospects", Oles` Petriv
Fwdays
 
SWEBOK Guide and Software Services Engineering Education
Hironori Washizaki
 
DevBcn - Building 10x Organizations Using Modern Productivity Metrics
Justin Reock
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
"AI Transformation: Directions and Challenges", Pavlo Shaternik
Fwdays
 
COMPARISON OF RASTER ANALYSIS TOOLS OF QGIS AND ARCGIS
Sharanya Sarkar
 
Log-Based Anomaly Detection: Enhancing System Reliability with Machine Learning
Mohammed BEKKOUCHE
 

Taking Advantage of Microsoft PowerShell

  • 1. Taking Advantage of Microsoft PowerShell Presented by Jared Thibodeau
  • 2. © Global Knowledge Training LLC. All rights reserved. Page 2 Presenter Jared Thibodeau Microsoft Operations Instructor at Global Knowledge • bilingual, cross-certified instructor with hands-on implementation experience and over • 20 years of IT consulting and teaching experience • Windows NT, Server 2000-2016, Windows XP-10, SharePoint 2007-2016, System Center, SCCM, SCOM, VMware and Hyper-V Virtualization, Cloud and many others.
  • 3. Topic 1 What you can administer with PowerShell
  • 4. © Global Knowledge Training LLC. All rights reserved. Page 4 Windows PowerShell overview • Introduced in 2006 • Both a CLI and scripting language • Commands include: • Cmdlets (pronounced command-lets) • Functions • Filters • Workflows • Microsoft server applications provide application- specific cmdlets • Now open-source and supports Linux and macOS
  • 5. © Global Knowledge Training LLC. All rights reserved. Page 5 Windows PowerShell vs. operating system • Windows PowerShell ships with specific core, native functionality • Most of its use, however, comes from extensions―additional commands that extend the capabilities of Windows PowerShell • Extensions are designed to work with a specific version of Windows PowerShell, but they do not ship with Windows PowerShell itself • Instead, extensions are provided as part of an operating system or a specific product version
  • 6. © Global Knowledge Training LLC. All rights reserved. Page 6 Two host applications • Console • Basic command-line interface • Maximum support for PowerShell features • Minimal editing capabilities • ISE • Script editor and console combination • Some Windows PowerShell features not supported • Rich editing capabilities • Third-party hosting applications/editors • Varying features and pricing
  • 7. © Global Knowledge Training LLC. All rights reserved. Page 7 Working in mixed-version environments • Many organizations must operate environments that contain more than one version of Windows PowerShell • Use $PSVersionTable to determine the version of Windows PowerShell on a computer
  • 8. © Global Knowledge Training LLC. All rights reserved. Page 8 Precautions when opening Windows PowerShell • 64-bit operating systems include 64-bit and 32-bit versions • 32-bit versions carry (x86) designation on icon and window title bar • Be certain you are opening the appropriate version for the task at hand • Usually, open the 64-bit version if it is available • Ensure that the window title bar displays Administrator if you need administrative privileges in Windows PowerShell • When UAC is enabled, you must right-click the application icon to run as Administrator • Always verify the window title bar contents when opening Windows PowerShell
  • 9. © Global Knowledge Training LLC. All rights reserved. Page 9 Configuring the ISE • Two panes: script and console • One-pane and two-pane view options • Command Add-on displays available commands • Customization of font style, size, and color • Customization of screen color • Bundling of color selections into themes • Additional features include snippets, add-ins, and debugging
  • 10. Topic 2 How to find and execute PowerShell commands
  • 11. © Global Knowledge Training LLC. All rights reserved. Page 11 Lesson 2: Understanding command syntax Cmdlet structure Parameters Tab completion Using Get-Help Demonstration: Viewing help Interpreting the help syntax Updating help About files Demonstration: Using About files
  • 12. © Global Knowledge Training LLC. All rights reserved. Page 12 Cmdlet structure • Verb is the action the cmdlet performs: • Get • Set • New • Add • Remove • Noun is the resource the cmdlet affects: • Service • Process • Prefixes used to group related nouns: • AD, SP, and AzureAD
  • 13. © Global Knowledge Training LLC. All rights reserved. Page 13 Parameters • Parameters modify the action of a cmdlet • Names are entered starting with a dash (-) • Parameters can be optional or required • You will receive prompts for required parameters, if needed • Some accept multiple values, separated by commas • Parameter name is optional for positional parameters
  • 14. © Global Knowledge Training LLC. All rights reserved. Page 14 Tab completion • Allows you to enter cmdlet, parameter, variable, and path names more quickly and accurately • Helps you to discover cmdlets and parameters • Supports the use of wildcards
  • 15. © Global Knowledge Training LLC. All rights reserved. Page 15 Using Get-Help • Displays Windows PowerShell help content • You provide a cmdlet name to display help for a cmdlet • Supports wildcards • Parameters include: • -Examples • -Full • -Online • -ShowWindow • -Parameter ParameterName
  • 16. © Global Knowledge Training LLC. All rights reserved. Page 16 Demonstration: Viewing help In this demonstration, you will see how to use various options of the help system
  • 17. © Global Knowledge Training LLC. All rights reserved. Page 17 Interpreting the help syntax Parameter set Mandatory parameter Positional parameter Optional parameter
  • 18. © Global Knowledge Training LLC. All rights reserved. Page 18 About files • Provide documentation for global shell techniques, concepts, and features • Start with about_ • View list by running Get-Help about* • You will need to read many of these files to complete several upcoming lab exercises
  • 19. © Global Knowledge Training LLC. All rights reserved. Page 19 Demonstration: Using About files In this demonstration, you will see how to use the About help file topics
  • 20. © Global Knowledge Training LLC. All rights reserved. Page 20 Lesson 3: Finding commands What are modules? Demonstration: Viewing modules Finding cmdlets Demonstration: Searching for cmdlets What are aliases? Demonstration: Using aliases Using Show-Command
  • 21. © Global Knowledge Training LLC. All rights reserved. Page 21 What are modules? • Modules: • Are containers for related cmdlets • Are provided as part of management tools for various software packages • Must be loaded into current session • Windows PowerShell version 3.0 and newer support autoloading • Autoloading requires Windows Server 2012/ Windows 8 or newer
  • 22. © Global Knowledge Training LLC. All rights reserved. Page 22 Demonstration: Viewing modules In this demonstration, you will see: • How to find installed modules • How autoloading and manual loading of modules work
  • 23. © Global Knowledge Training LLC. All rights reserved. Page 23 Finding cmdlets • Use Get-Command and Get-Help, both of which support wildcards • Use –Noun, –Verb, and –Module parameters with Get-Command • Get-Help can also search the content of help files if no match is found when searching command names • Use the PowerShellGet module to find modules and commands from the PowerShell Gallery
  • 24. © Global Knowledge Training LLC. All rights reserved. Page 24 Demonstration: Searching for cmdlets In this demonstration, you will see how to use several techniques to discover new cmdlets
  • 25. © Global Knowledge Training LLC. All rights reserved. Page 25 What are aliases? • Familiar batch commands include: • Dir • Cd • Mkdir • Type • These are really aliases to Windows PowerShell commands • External commands such as ping.exe and ipconfig.exe all work as usual • Windows PowerShell commands often have a different syntax, even if accessed by an alias that matches an older command name
  • 26. © Global Knowledge Training LLC. All rights reserved. Page 26 Demonstration: Using aliases In this demonstration, you will see how to: • Find an alias for a cmdlet • Find a cmdlet based on an alias you already know • Create an alias
  • 27. © Global Knowledge Training LLC. All rights reserved. Page 27 Using Show-Command
  • 28. Topic 3 How to format information and combine multiple PowerShell commands
  • 29. © Global Knowledge Training LLC. All rights reserved. Page 29 Module Overview Understanding the pipeline Selecting, sorting, and measuring objects Filtering objects out of the pipeline Enumerating objects in the pipeline Sending pipeline data as output
  • 30. © Global Knowledge Training LLC. All rights reserved. Page 30 Lesson 1: Understanding the pipeline What is the pipeline? Pipeline output Discovering object members Demonstration: Viewing object members Formatting pipeline output Demonstration: Formatting pipeline output
  • 31. © Global Knowledge Training LLC. All rights reserved. Page 31 What is the pipeline? • Windows PowerShell runs commands in a pipeline • Each console command line is a pipeline • Commands separated by a pipe character (|) • Commands execute from left to right • Output of each command is piped (passed) to the next • The output of the last command in the pipeline is what appears on your screen • Piped commands typically follow the pattern Get |Set, Get | Where, or Select | Set
  • 32. © Global Knowledge Training LLC. All rights reserved. Page 32 Pipeline output • Windows PowerShell commands produce objects as their output • An object is like a table of data in memory • Allows the Get | Set pattern to work Name Status DisplayName WinRM Running Windows Remote Management VDS Running Virtual Disk Property Object Collection
  • 33. © Global Knowledge Training LLC. All rights reserved. Page 33 Discovering object members • Object members include: • Properties • Methods • Events • Run a command that produces an object, and pipe that object to Get-Member to see a list of members • Get-Member is a discovery tool, similar to Help, that can help you learn to use the shell
  • 34. © Global Knowledge Training LLC. All rights reserved. Page 34 Demonstration: Viewing object members In this demonstration, you will see how to run commands in the pipeline and how to use Get- Member
  • 35. © Global Knowledge Training LLC. All rights reserved. Page 35 Formatting pipeline output • Use the following cmdlets to format pipeline output: • Format-List • Format-Table • Format-Wide • The -Property parameter: • Is common to all formatting cmdlets • Filters output to specified property names • Can only specify properties that were passed to the formatting command
  • 36. © Global Knowledge Training LLC. All rights reserved. Page 36 Demonstration: Formatting pipeline output In this demonstration, you will see how to format pipeline output
  • 37. © Global Knowledge Training LLC. All rights reserved. Page 37 Creating calculated properties • Calculated (custom) properties let you choose the output label and contents • Each calculated property works like a single regular property in the property list accepted by Select-Object • Create calculated properties by using a specific syntax: • Label defines the property name • Expression defines the property contents • Within the expression, $PSItem (or $_) refers to the piped-in object
  • 38. © Global Knowledge Training LLC. All rights reserved. Page 38 Creating calculated properties @{ n='VirtualMemory'; e={ $PSItem.VM } } Hash table Label key Label string value Expression key Expression script block Semicolon Calculated property hash table
  • 39. © Global Knowledge Training LLC. All rights reserved. Page 39 Demonstration: Creating calculated properties In this demonstration, you will see how to use Select-Object to create calculated properties. You will then see how those calculated properties behave like regular properties.
  • 40. © Global Knowledge Training LLC. All rights reserved. Page 40 Lesson 5: Sending pipeline data as output Writing output to a file Converting output to CSV Converting output to XML Converting output to JSON Converting output to HTML Demonstration: Exporting data Additional output options
  • 41. © Global Knowledge Training LLC. All rights reserved. Page 41 Writing output to a file • Out-File writes whatever is in the pipeline to a text file • The > and >> redirection operators are also supported • The text file is formatted exactly the same as the data would have appeared on the screen―no conversion to another form occurs • Unless the data has been converted to another form, the resulting text file is usually suitable for viewing only by a person • As you start to build more complex commands, you need to keep track of what the pipeline contains at each step
  • 42. © Global Knowledge Training LLC. All rights reserved. Page 42 Converting output to CSV • The commands are: • ConvertTo-CSV • Export-CSV • The commands send: • Properties as headers • No type information • You can easily open large CSV files in Excel
  • 43. © Global Knowledge Training LLC. All rights reserved. Page 43 Converting output to XML • ConvertTo-CliXml • Export-CliXml • Portable data format • Multivalue properties become individual entries
  • 44. © Global Knowledge Training LLC. All rights reserved. Page 44 Converting output to JSON • The command is • ConvertTo-JSON • The advantages are: • Compactness • Ease of use, especially with JavaScript • A format like a hash table
  • 45. © Global Knowledge Training LLC. All rights reserved. Page 45 Converting output to HTML • The command is ConvertTo-HTML • The command creates a table or list in HTML • You must pipe the output to a file • The parameters include: • -Head • -Title • -PreContent • -Postcontent
  • 46. © Global Knowledge Training LLC. All rights reserved. Page 46 Demonstration: Exporting data In this demonstration, you will see different ways to convert and export data
  • 47. © Global Knowledge Training LLC. All rights reserved. Page 47 Additional output options • Out-Host allows more control of on-screen output • Out-Printer sends output to a printer • Out-GridView creates an interactive, spreadsheet-like view of the data
  • 48. Topic 4 How to perform actions on remote computers using PowerShell
  • 49. © Global Knowledge Training LLC. All rights reserved. Page 49 Module Overview Using basic Windows PowerShell remoting Using advanced Windows PowerShell remoting techniques Using PSSessions
  • 50. © Global Knowledge Training LLC. All rights reserved. Page 50 Lesson 1: Using basic Windows PowerShell remoting Remoting overview and architecture Remoting vs. remote connectivity Remoting security Enabling remoting Using remoting: one-to-one Using remoting: one-to-many Demonstration: Enabling and using remoting Remoting output vs. local output
  • 51. © Global Knowledge Training LLC. All rights reserved. Page 51 Remoting overview and architecture Remoting: • Uses WS-MAN protocol, using HTTP (by default) or HTTPS • Is implemented by WinRM service • Is enabled by default on Windows Server 2016; available on any computer running Windows PowerShell 2.0 or greater • Is not enabled on any client operating system • Must be enabled on any computer that will receive incoming connections
  • 52. © Global Knowledge Training LLC. All rights reserved. Page 52 Remoting vs. remote connectivity • Remoting is the name of a specific feature that utilizes a specific service and protocol • When used in Windows PowerShell, use the term Windows PowerShell remoting • It applies to a relatively small subset of commands that can communicate with remote computers • A command with a –ComputerName parameter does not necessarily mean it uses remoting • Nonremoting commands use their own protocols: • RPCs, which include WMI • Remote Registry Service (for example, Get-Process)
  • 53. © Global Knowledge Training LLC. All rights reserved. Page 53 Remoting security • Remoting is security transparent; you can perform only those tasks that your credentials allow • Mutual authentication helps prevent delegation of credentials to spoofed or impersonated computers: • It works in domain environments by default • It can use SSL in lieu of domain credentials • It can be disabled through the TrustedHosts list
  • 54. © Global Knowledge Training LLC. All rights reserved. Page 54 Remoting security Remoting privacy: • Channel-level encryption is provided only with HTTPS connections • Application-level encryption is provided with all connections • Credentials are transmitted in clear text only with the Basic authentication protocol when HTTPS is not in use (for example, to a nondomain computer on TrustedHosts list) • You cannot use Basic authentication unless you enable unencrypted traffic in the client configuration
  • 55. © Global Knowledge Training LLC. All rights reserved. Page 55 Enabling remoting • To enable Windows PowerShell remoting manually, run Enable- PSRemoting as an Administrator • To enable Windows PowerShell remoting centrally, configure a GPO • There are restrictions on client computers where a network connection is set to Public • Windows Server 2012 and later enable Windows PowerShell remoting by default; no further steps are needed
  • 56. © Global Knowledge Training LLC. All rights reserved. Page 56 Using remoting: one-to-one One-to-one Windows PowerShell remoting is similar in concept to SSH, although different in actual operation: 1. Start with Enter-PSSession –ComputerName name 2. The Windows PowerShell prompt changes to indicate the connected computer 3. Exit with Exit-PSSession
  • 57. © Global Knowledge Training LLC. All rights reserved. Page 57 Using remoting: one-to-many • Invoke-Command can send a command or script to one or more remote computers in parallel • Results include a PSComputerName property that indicate the computer each result came from • Considerations include: • Throttling • Passing data to remote computers • Persistence • Ways to specify computer names
  • 58. © Global Knowledge Training LLC. All rights reserved. Page 58 Demonstration: Enabling and using remoting In this demonstration, you will see how to enable remoting on a client computer, and how to use remoting in several basic scenarios
  • 59. © Global Knowledge Training LLC. All rights reserved. Page 59 Remoting output vs. local output • Results received through remoting are deserialized from XML • As a result, they are not live objects and do not have methods or events • As a strategy, try to have as much processing as possible occur on the remote computer, with only the final results coming back to you through remoting
  • 60. © Global Knowledge Training LLC. All rights reserved. Page 60 Lesson 2: Using advanced Windows PowerShell remoting techniques Common remoting options Sending parameters to remote computers Windows PowerShell scopes Demonstration: Sending local variables to a remote computer Multi-hop remoting
  • 61. © Global Knowledge Training LLC. All rights reserved. Page 61 Common remoting options • –Port • –UseSSL • –Credential • –ConfigurationName • –Authentication • Additional options are available by creating a PSSessionOption object, and then passing it to –SessionOption
  • 62. © Global Knowledge Training LLC. All rights reserved. Page 62 Sending parameters to remote computers • You cannot use local variables in the Invoke-Command script block • You can pass data. However, you must use a specific technique • Pass local variables to the –ArgumentList parameter of Invoke-Command; they will map to variables in a Param() block inside the script block
  • 63. © Global Knowledge Training LLC. All rights reserved. Page 63 Multi-hop remoting 1 2
  • 64. © Global Knowledge Training LLC. All rights reserved. Page 64 Lesson 3: Using PSSessions Persistent connections Creating a PSSession Using a PSSession Demonstration: Using PSSessions Disconnected sessions Demonstration: Disconnected sessions Implicit remoting Demonstration: Implicit remoting
  • 65. © Global Knowledge Training LLC. All rights reserved. Page 65 Persistent connections • PSSessions: • Represent a persistently running connection on the remote computer • Can execute multiple sequences of commands, be disconnected, reconnected, and closed • Numerous configuration parameters in the drive WSMan control idle session time and maximum connections
  • 66. © Global Knowledge Training LLC. All rights reserved. Page 66 Creating a PSSession • Create sessions by using New-PSSession; the command produces a reference to the PSSessions it creates • Assign PSSessions to variables to make them easier to refer to later
  • 67. © Global Knowledge Training LLC. All rights reserved. Page 67 Using a PSSession • Pass a session object to the –Session parameter of Enter- PSSession to interactively enter that session • Alternatively, pass session object(s) to the –Session parameter of Invoke-Command to run a command against those PSSessions • The PSSessions remain open and connected after you are finished, leaving them ready for additional use
  • 68. © Global Knowledge Training LLC. All rights reserved. Page 68 Demonstration: Using PSSessions In this demonstration, you will see how to create and manage PSSessions
  • 69. © Global Knowledge Training LLC. All rights reserved. Page 69 Disconnected sessions • Disconnect-PSSession disconnects from a PSSession while leaving Windows PowerShell running: • Does not happen automatically when you close the host application • Get-PSSession –ComputerName displays a list of your PSSessions on the specified computer: • You cannot see other users’ PSSessions • Connect-PSSession reconnects a PSSession, making it available for use
  • 70. © Global Knowledge Training LLC. All rights reserved. Page 70 Demonstration: Disconnected sessions In this demonstration, you will see how to: • Create a PSSession • Disconnect a PSSession • Display PSSessions • Reconnect a PSSession
  • 71. © Global Knowledge Training LLC. All rights reserved. Page 71 Implicit remoting • Imports commands from a remote computer to the local one: • Imported commands still run on the remote computer through an established remoting session • Lets you utilize commands without needing to install them • Help is also drawn from the remote computer
  • 72. © Global Knowledge Training LLC. All rights reserved. Page 72 Demonstration: Implicit remoting In this demonstration, you will see how to use implicit remoting to import and use a module from a remote computer
  • 73. © Global Knowledge Training LLC. All rights reserved. Page 73 Courses Automating Administration with Windows PowerShell Advanced Automated Administration Windows PowerShell Scripting and Toolmaking
  • 74. © Global Knowledge Training LLC. All rights reserved. Page 74 Learning More GlobalKnowledge.com For additional on-demand and live webinars, white papers, courses, special offers and more, visit us at…