Introduction to PowerShell Remoting, Part 2<br />Matt Johnson, GSEC, MCSE<br />matt@michiganpowershell.com<br />
What are we going to cover?<br />Remote Commands<br />Reusable  Sessions with PS Remoting<br />Interactive Sessions with P...
Remote Commands<br />New-PSSession<br />Get-PSSession<br />Enter-PSSession<br />Exit-PSSession<br />Remove-PSSession<br />...
PS Remoting Help<br />Get-Help <br />about_Remoting<br />about_PSSessions<br />about_Remote_Requirements<br />about_Remote...
Reusable  Sessions with PS Remoting<br />It is really easy to create  a new PS Session<br />$dc = New-PSSession –computerN...
Reusable  Sessions with PS Remoting Cont..<br />Less network / CPU cycles used when using Reusable sessions compared to ru...
Demo<br />
Running Commands against muliple machines<br />$sessions = New-PSSession pc1, pc2, pc3<br />Invoke-Command { Md HKLM:Softw...
Passing Variables to Remote Hosts<br />You can pass variables to the Invoke-Command cmdlet<br />Your script block must use...
Demo<br />
Interactive Sessions<br />Run at a console just like you are sitting there at the machine. <br />Run all normal PowerShell...
Demo<br />
Code to change what is allowed to run<br /># Disable access to all applications<br />$ExecutionContext.SessionState.Applic...
Code to change what is allowed to run cont.<br />Save as:<br />%windir%system32WindowsPowerShellv1.0
estricted.ps1<br />
Running single commands<br />Use Invoke-Command<br />Results are returned as text, not as objects<br />Adds some overhead ...
DEMo<br />
Remoting Resources<br />Two very useful resources!<br />Get-Help<br />PowerShell.com’s Administrators Guide to PowerShell ...
Contact<br />Matt Johnson<br />Phone: +1 (734) 931-0323<br />Web: http://www.mwjcomputing.com/<br />Blog: http://www.mwjco...
Thanks!<br />
Upcoming SlideShare
Loading in …5
×

April 2010-intro-to-remoting-part2

1,327
-1

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,327
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
7
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

April 2010-intro-to-remoting-part2

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

    Recortar diapositivas es una manera útil de recopilar información importante para consultarla más tarde.

×