• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
April 2010-intro-to-remoting-part2
 

April 2010-intro-to-remoting-part2

on

  • 704 views

 

Statistics

Views

Total Views
704
Views on SlideShare
702
Embed Views
2

Actions

Likes
0
Downloads
6
Comments
0

2 Embeds 2

http://www.slideshare.net 1
http://www.techgig.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    April 2010-intro-to-remoting-part2 April 2010-intro-to-remoting-part2 Presentation Transcript

    • Introduction to PowerShell Remoting, Part 2
      Matt Johnson, GSEC, MCSE
      matt@michiganpowershell.com
    • What are we going to cover?
      Remote Commands
      Reusable Sessions with PS Remoting
      Interactive Sessions with PS Remoting
      Temporary Sessions with PS Remoting
    • Remote Commands
      New-PSSession
      Get-PSSession
      Enter-PSSession
      Exit-PSSession
      Remove-PSSession
      Invoke-Command
    • PS Remoting Help
      Get-Help
      about_Remoting
      about_PSSessions
      about_Remote_Requirements
      about_Remote_FAQ
      about_Remote_Troubleshooting
    • Reusable Sessions with PS Remoting
      It is really easy to create a new PS Session
      $dc = New-PSSession –computerName DC1
      It is also really easy to enter that session
      Enter-PSSession –Session $dc
      More about that later!
    • Reusable Sessions with PS Remoting Cont..
      Less network / CPU cycles used when using Reusable sessions compared to running individual commands.
      You can run one off commands if you are using Reusable sessions
      Use Reusable sessions when you need to run more than one command against a computer.
    • Demo
    • Running Commands against muliple machines
      $sessions = New-PSSession pc1, pc2, pc3
      Invoke-Command { Md HKLM:Softwaremwjcomputing } –Session $sessions
    • Passing Variables to Remote Hosts
      You can pass variables to the Invoke-Command cmdlet
      Your script block must use the param statement
      Use the –ArgumentList switch
    • Demo
    • Interactive Sessions
      Run at a console just like you are sitting there at the machine.
      Run all normal PowerShell commands
      You can restrict the commands that can be run remotely.
    • Demo
    • Code to change what is allowed to run
      # Disable access to all applications
      $ExecutionContext.SessionState.Applications.Clear()
      # Disable access to scripts
      $ExecutionContext.SessionState.Scripts.Clear()
      # Define a list of allowed commands
      $RequiredCommands = "Exit-PSSession", "Get-Command", "Get-FormatData", "Get-Help", "Measure-Object", "Out-Default", "Select-Object"
      $Commands = $RequiredCommands + "Get-Process", "Get-Service", "Where-Object", "ForEach-Object"
      # Make everything except the allowed commands private (not visible)
      Get-Command | Where-Object {$Commands -notcontains $_.Name} | ForEach-Object {$_.Visibility="Private"}
      # Restrict the language elements to a very limited set. The possible values are FullLanguage,RestrictedLanguage, and NoLanguage
      $ExecutionContext.SessionState.LanguageMode="RestrictedLanguage"
    • Code to change what is allowed to run cont.
      Save as:
      %windir%system32WindowsPowerShellv1.0 estricted.ps1
    • Running single commands
      Use Invoke-Command
      Results are returned as text, not as objects
      Adds some overhead by doing it this way
    • DEMo
    • Remoting Resources
      Two very useful resources!
      Get-Help
      PowerShell.com’s Administrators Guide to PowerShell Remoting
    • Contact
      Matt Johnson
      Phone: +1 (734) 931-0323
      Web: http://www.mwjcomputing.com/
      Blog: http://www.mwjcomputing.com/blog/
      Twitter: http://twitter.com/mwjcomputing
      Email: matt@michiganpowershell.com
    • Thanks!