[webinar] powershell series part 3 – powershell and wmi

Click here to load reader

Post on 07-Jul-2015

158 views

Category:

Software

5 download

Embed Size (px)

DESCRIPTION

PowerShell and Windows Management Instrumentation (WMI) are both great on their own but when you combine these two tools, you have an even more flexible and powerful solution. In part 3 of this PowerShell series, we will show you how to use and leverage WMI with Windows PowerShell

TRANSCRIPT

  • 1. POWERSHELL AND WMIDiscovering your environment in a meaningful wayKevin Sullivan Specops SoftwareDarren Mar-Elia SDM Software

2. WHOAMIWelcome Kevin Sullivan [email protected] @kevsully67 Director of Sales Engineering Recovering GP MVP, Musician Previously Principal Program Manager at Microsoft Technology lover geek dad 3. Darren Mar-Elia 30 years of experience in enterprise IT and software Founder, in 2006, of Group Policy solutionscompany SDM Software, Inc.(www.sdmsoftware.com) Wrote the first PowerShell cmdlets for Group Policy! Microsoft Group Policy MVP for the last 11 years Contributing Editor to Windows IT Pro Magazinesince 1997 Founder of GPOGUY.COMa Group Policy resourcesite3 4. WWW.SDMSOFTWARE.COMSDM Software Founded in 2006, by Darren Mar-EliaGroupPolicy MVP with 30 years experience in IT &Enterprise Software Provides Group Policy Reporting, Auditing andCompliance solutions to over 300 customersworldwide Freeware tools for Group Policy management to1000s of users WWW.GPOGUY.COM resource site for GP technicalquestions (GPTalk Forum) 5. LET IT FLOWStream of Consciousness 6. What is Windows ManagementInstrumentation (WMI)? Based on the DMTF Common Information Model(CIM) standard Industry-standard for describing systems and theircomponents WMI is the CIM implementation for Windows But, lots of CIM implementations on other platforms Linux, network devices, etc. See Open Management Instrumentation (OMI)Microsofts open source CIM framework 7. What is WMI For? Provides a standard mechanism for describingWindows system configuration And allow some manipulation of it Provides the basis for Desired State Configuration(DSC) in PowerShell v4+ Accessible remotely via DCOM (old way) or WinRM(WS-Management implementation) 8. How WMI Works Creates a hierarchy of System Configuration stuff Namespaces Classes Properties Methods Configuration elements are instances of classes e.g. the Spooler service is an instance of the Win32_Service class Instances have properties (e.g. State property equals Running) andMethods (Stop() method to stop the service) You can query instances using WMI Query Language (WQL) Select * from Win32_Service Where Name = spooler 9. PowerShell & WMI Microsoft started by providing a single cmdlet to getaccess to WMI instances on local or remote systems: Get-WMIObject In PowerShell v4, introduced the CIM Cmdlets Think a more raw (and flexible) way of getting to WMIdata (e.g.) Get-CIMInstance Invoke-CIMMethod 10. FORMATTING OUTPUT 11. WHAT IS IN THE OBJECTExploring Objects Get-Member MemberType Properties Methods 12. THE SUPER BASICFormat Right Guidance received from the experts Don Jones & Jeffrey Hicks PowerShell in a Month Of Lunches Get this book And PS Toolmaking in a Month of Lunches Figure out everything first What data/objects do you want to retrieve Sort/organize/filter/query etc Perfume the Pig! (Format) 13. Select-Object / Where-Object Cmdlets return object(s) Could be many Need to filter down to something manageable oruseable Need to Organize output to make results easier toparse 14. Format-Table FT Dont use alias if you are sharing! Default Views Dir $pshome Look for ps1xml files Define default output for cmdlets Creating Custom views Out-of-Scope (but pretty cool) http://msdn.microsoft.com/en-us/library/gg580944(v=vs.85).aspx 15. Format-List FL Dont use Alias if you are sharing! If the default output of an object is more than sixcolumns it will default to a list Properties shown in a stack Great for looking at details as you figure out what todo 16. Format-Wide Quick results Easy to read on the screen Great when digging in deeper Progressiveexploration 17. Out-GridView As we say in Boston Wicked Pissah! Sort Manipulate Quick Export-CSV open in Excel Better, but more steps and not as quick For saving and sharing long term Export and Excel isway better 18. Default Formats $pshome Ps1xml files defining default output Open in notepad to explore contents BE CAREFUL Object types Get-EventLog LogName Applcation | Get-Member 19. WHAT DOES THE FUTURE BRING?Wrap-up Questions Next month? Send feedback [email protected] 20. LOTS OF RESOURCESResources Http://www.SpecopsSoft.com Http://success.SpecopsSoft.com Http://sdmsoftware.com 21. LOTS OF RESOURCESResources http://www.powershellpro.com Some great tutorials http://powershell.org http://technet.Microsoft.com/scriptcenter Repository! http://jdhitsolutions.com/blog Jeff Hicks PowerShell help system! http://www.specopssoft.com http://success.specopssoft.com