PowerShell for monitoring and managing Windows 7 desktops remotely

18
virtual techdays INDIA 9-11 February 2011 Monitoring and managing remote Windows 7 desktops with Windows PowerShell Ravikanth C Dell Inc.

description

This is the deck I used for Virtual Tech Days session in Feb' 2011

Transcript of PowerShell for monitoring and managing Windows 7 desktops remotely

Page 1: PowerShell for monitoring and managing Windows 7 desktops remotely

virtual techdaysINDIA │ 9-11 February 2011

Monitoring and managing remote Windows 7 desktops with Windows PowerShellRavikanth C │ Dell Inc.

Page 2: PowerShell for monitoring and managing Windows 7 desktops remotely

About Me• Work at Dell Inc.• Windows PowerShell MVP• Author of:• Free eBook: Layman’s guide to PowerShell 2.0 remoting• Free eBook: WMI Query Language via PowerShell• Cheat Sheet: SharePoint 2010 PowerShell cmdlets

• Blog at: http://www.ravichaganti.com/blog• Twitter: @Ravikanth

Page 3: PowerShell for monitoring and managing Windows 7 desktops remotely

Session Outline• Objectives• What is PowerShell?• Cmdlets to manage remote systems• PowerShell remoting for remote system management• PowerShell for WMI event monitoring• Software & hardware inventory

• Takeaways• Learn how to use PowerShell cmdlets to manage remote

systems• Learn how to use PowerShell remoting• Learn how to monitor remote systems using WMI

Page 4: PowerShell for monitoring and managing Windows 7 desktops remotely

What is PowerShell?• Object-based Shell• Interactive commands

• Scripting language• Automate everything • Sharable and reusable

• Comes built-in on Windows 7 & Windows Server 2008 R2

• Download available for Windows XP, Windows 2003, and Windows Vista

Page 5: PowerShell for monitoring and managing Windows 7 desktops remotely

Cmdlets to manage remote systems• 35 cmdlets with –ComputerName parameter• Get-Command -type cmdlet | Where {

$_.Definition -like "*-ComputerName*"}

Page 6: PowerShell for monitoring and managing Windows 7 desktops remotely

Working with performance data• One cmdlet• Get-Counter

• Gets live, real-time performance counter data• Sample interval and Maximum samples can be

altered• Run as administrator to be able to read all

counters

Page 7: PowerShell for monitoring and managing Windows 7 desktops remotely

virtual techdaysINDIA │ 9-11 February 2011

DEMO: Working with Performance Data

Page 8: PowerShell for monitoring and managing Windows 7 desktops remotely

Working with processes• Five cmdlets• Get-Process• Debug-Process• Start-Process• Stop-Process• Wait-Process

• Start-Process and Stop-Process have no –ComputerName Parameter

Page 9: PowerShell for monitoring and managing Windows 7 desktops remotely

virtual techdaysINDIA │ 9-11 February 2011

DEMO: Working with processes

Page 10: PowerShell for monitoring and managing Windows 7 desktops remotely

PowerShell remoting• Not all remoting is the same• Get-Process, Get-Service, and others use .NET

Framework methods• Not all cmdlets have –ComputerName parameter• Remoting requirements:• Windows PowerShell 2.0 • Microsoft .NET Framework 2.0 or later• Windows Remote Management 2.0

• To configure PowerShell remoting: • start PowerShell as admin• Use Enable-PSRemoting

Page 11: PowerShell for monitoring and managing Windows 7 desktops remotely

Remoting Methods• Supports both fan-in and fan-out remoting• Invoke-Command• Can be used for both 1-1 and 1-many remoting

• Interactive remoting• Similar to a telnet session• Enter-PSSession

• Implicit remoting• Import a remote session into local session• Import-PSSession

Page 12: PowerShell for monitoring and managing Windows 7 desktops remotely

virtual techdaysINDIA │ 9-11 February 2011

DEMO: PowerShell remoting

Page 13: PowerShell for monitoring and managing Windows 7 desktops remotely

WMI Event monitoring• Events generated by operating system and

several other components• Use Register-WMIEvent cmdlet• Create temporary consumer to trigger an action

based on an event• Requires knowledge of WMI Query Language• Unregister-Event to delete the consumer

Page 14: PowerShell for monitoring and managing Windows 7 desktops remotely

virtual techdaysINDIA │ 9-11 February 2011

DEMO: WMI Event monitoring

Page 15: PowerShell for monitoring and managing Windows 7 desktops remotely

Software Inventory• Use Get-WMIObject cmdlet• For remote systems use –ComputerName parameter• Query Win32_Product WMI class

• For software installed via MSI• Install & Uninstall software remotely• Query Windows registry for a list of all other

software

Page 16: PowerShell for monitoring and managing Windows 7 desktops remotely

virtual techdaysINDIA │ 9-11 February 2011

DEMO: Software Inventory

Page 17: PowerShell for monitoring and managing Windows 7 desktops remotely

virtual techdaysINDIA │ 9-11 February 2011

RESOURCES

PowerShell remoting ebooks Layman’s guide to PowerShell remoting: http://www.ravichaganti.com/blog/?p=1780 Administrator’s guide to PowerShell remoting: http://

powershell.com/cs/media/p/4908.aspx WMI Query Language

http://www.ravichaganti.com/blog/?p=1979 Getting started with PowerShell

http://technet.microsoft.com/en-us/scriptcenter/dd742419

Page 18: PowerShell for monitoring and managing Windows 7 desktops remotely

virtual techdaysTHANKS│9-11 February 2011

[email protected] │ @Ravikanth (Twitter)