PowerShell 2 remoting


Published on

Published in: Technology
1 Like
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

PowerShell 2 remoting

  1. 1. PowerShell 2.0 remotingUK PowerShell User Group<br />Jonathan Medd<br />
  2. 2. I have a dream...........<br />
  3. 3. Ben Pearce, Microsoft PFE, gave me that dream in Oct 2008.......<br />
  4. 4. ......and now that dream has come true!<br />PowerShell Remoting is here and I can manage my entire Windows estate from the comfort of my Home Cinema.<br />
  5. 5. PowerShell 2.0 – New Cmdlets with Remoting Functionality<br />PowerShell 1.0 only had Get-WmiObject -Computername<br />PowerShell 2.0 has 35 cmdlets with ComputerNameparamter<br />Examples: Get-Service, Restart-Computer, Write-EventLog<br />Use protocols such as RPC & DCOM<br />Find them with Get-Command | Where-Object {$_.definition -match 'computername'}<br />
  6. 6. Software Requirements for Full-Fat Remoting<br /><ul><li>Typically HTTP on port 5985, open for WinRM 2.0. HTTPS on (5986)</li></ul>PowerShell 2.0 and WinRM 2.0<br />So either:<br />Windows Server 2008 R2 or Windows 7<br />Windows Server 2003 or Windows XP and later with the Windows Management Framework Installed which includes PowerShell 2.0 and WinRM 2.0<br />
  7. 7. Enable-PSRemoting<br />Run as administrator<br />Confirmation of changes<br />
  8. 8. Additional Requirements if in Workgroup not Domain<br />If OS is XP then set Network Access: Sharing and Security Model for local accounts)to Classic.<br />Then, for any Windows Operating System, including Windows XP, you will need to add the names of the remote computer(s) into the TrustedHosts setting of WinRM<br />Set-Item WSMan:localhostClientTrustedHosts-valueServerName<br />
  9. 9. Enable via Group Policy<br />Allow automatic configuration of listeners<br />Computer ConfigurationPoliciesAdministrative TemplatesWindows ComponentsWindows Remote ManagementWinRM Service<br />
  10. 10. Manual Firewall Settings<br />Enable Windows Remote Management<br />
  11. 11. Interactive PowerShell Remoting<br />Enter-PSSession –ComputerNameServer01<br />Similar to Telnet / SSH<br />Kerberos authentication by default, encryption can be added with SSL<br />Exit-PSSession when finished. Session is torn down at this point<br />
  12. 12. Interactive PowerShell Remoting Demo<br />
  13. 13. If we stopped at this point even this interactive story would be great……..<br />30 years of catch-up on remote command line management<br />
  14. 14. Persistent PowerShell Remoting<br />SSH is so 2007.....<br />
  15. 15. Persistent PowerShell Remoting<br />Let’s create multiple sessions and store them in a variable $sessions<br />$sessions = New-PSSession –ComputerName (Get-Content Servers.txt)<br />Can be accessed by cmdlets like Enter-PSSession or Invoke-Command<br />Are maintained after the session has been used, until timeout period expired<br />
  16. 16. Basic Session Options<br />New-PSSession Parameters:<br />-Credential: e.g. Domain01User01<br />-Name: a friendly name to refer to them with<br />-Port: alternate port number to use<br />-ThrottleLimit: max number of outbound sessions from this command, 32 by default<br />Other parameters are available, check Get-Help!<br />
  17. 17. Advanced Session Options<br />New-PSSessionOption Parameters:<br />-IdleTimeout: Default is 4 mins<br />-OpenTimeout<br />-OperationTimeout<br />-NoCompression<br />Other parameters are available, check Get-Help!<br />Used via New-PSSession -SessionOption<br />
  18. 18. Advanced Session Options Set at the Destination<br />Register-PSSessionConfiguration<br />Create customised session configurations to present to remote connections.<br />-StartupScript: most interesting parameter<br />Used via New-PSSession -ConfigurationName<br />
  19. 19. Using Persistent Sessions<br />Invoke-Command –Session $sessions –ScriptBlock {Get-Culture}<br />Note the PSComputerName Property returned<br />Invoke-Command –Session $sessions –FilePath C:ScriptsQueryServer.ps1<br />You can now run any existing script against all your remote servers<br />
  20. 20. If you’re using Windows and not retiring in the next 12 – 18 months, you need to learn PowerShell!<br />
  21. 21. Implicit PowerShell Remoting<br />Use Management Tools from remote servers on your client workstation<br />No need to install modules locally<br />Import-PSSession –Session $session –Module ActiveDirectory<br />All cmdlets from Active Directory module now available on local workstation<br />
  22. 22. Obligatory Cloud Slide<br />Exchange Online (BPOS)<br />$LiveCred = Get-Credential<br />$Session = New-PSSession -ConnectionUri https://ps.outlook.com/powershell/ -Credential $LiveCred -Authentication Basic -AllowRedirection<br />Import-PSSession $Session<br />A Cloud Service Provider can supply you with the tools you need to manage their service with no local installation required<br />
  23. 23. Links<br />Simple-Talk Article http://www.simple-talk.com/sysadmin/powershell/new-remoting-features-in-powershell-2.0/<br />Administrators Guide to PowerShell Remoting http://powershell.com/cs/media/p/4908.aspx<br />Layman’s Guide to PowerShell Remoting http://www.ravichaganti.com/blog/?p=1305<br />