inventory your network and clients with powershell
DESCRIPTION
TRANSCRIPT
![Page 1: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/1.jpg)
JUNE 7-10, 2010 | NEW ORLEANS, LA
![Page 2: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/2.jpg)
Inventory Your Network and Clientswith Windows PowerShellDon JonesSenior Partner and TechnologistConcentrated Technology, LLC
SESSION CODE: WCL308
![Page 3: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/3.jpg)
This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it within your own organization however you like.
For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site,
www.ConcentratedTech.com.
For links to newly-posted decks, follow us on Twitter:@concentrateddon or @concentratdgreg
This work is copyright ©Concentrated Technology, LLC
![Page 4: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/4.jpg)
IntroductionsMe: Don Jones, Concentrated Technology
Microsoft MVP Award recipientContributing Editor, TechNet MagazineAuthor of 45+ IT booksBlogger at http://ConcentratedTech.com
You: A Busy Windows AdministratorNeeding to inventory management information from one or more remote computers, both server and client (but especially client)
![Page 5: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/5.jpg)
AgendaWindows PowerShell, BrieflyWindows Management Instrumentation, BrieflyExploring WMIPlaying with WMI on Your Local ComputerUsing WMI on Remote ComputersMaking a Flexible WMI Tool in Steps
![Page 6: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/6.jpg)
Windows PowerShell, BrieflyThis session’s code will work with v1 and v2 (up until “advanced functions” at the very end – that’s v2 only)V1: Ships with Win2008 and Vista, available for WinXP and Win2003V2: Ships with Win2008R2 and Win7, available for WinXP, Win2003, Vista, and Win2008Primarily a command-line shell; has scripting capabilities, but we won’t be diving into them (much) – we’ll be using scripts as “batch files” mainlyNote: I make all scripts downloadable from my Web site, no need to take notes
![Page 7: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/7.jpg)
Security NotesWindows PowerShell disables script execution (but not commands) by default; see Help about_execution* for detailsWindows PowerShell is subject to User Account Control (UAC); for our purposes, ensure you explicitly run “as Administrator” for necessary remote privileges
![Page 8: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/8.jpg)
WMI, BrieflyPresent since Windows NT 4.0Does not require PowerShell on the remote computerUses Remote Procedure Calls (RPCs) for communication; does not require PowerShell v2 / WinRM “remoting” on remote machinesOrganized into:
Namespaces: Top-level, strictly organizational, usually product-relatedClasses: Represent potential manageable elementsInstances: Real-world occurrences of classesProperties & Methods: Elements of an instance
Properties contain management informationMethods perform actions (such as reconfiguration)
![Page 9: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/9.jpg)
WMI SecurityConfigured (by default) on the root namespaceTypically, don’t mess with this – many things rely on WMI and can get angry if you fuss with the permissionsUse WMI Control MMC snap-in to modify (or view – great way for seeing what namespaces are installed)
![Page 10: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/10.jpg)
WMI Security and Namespaces
DEMO
![Page 11: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/11.jpg)
Differences from Machine to MachineWMI namespaces will vary based on the roles/products/technologies installed on a computerIndividual classes will vary based on product or Windows versionClasses’ properties and methods can vary from version to version, too
Core Windows OS and hardware stuff is in \root\CIMv2; most classes start with Win32_ or CIM_ prefix in the class name
Best to get a “WMI Explorer” or “WMI Browser” that can be focused at a remote computer to see what that computer hasYou don’t need a class on your computer in order to query it from a remote computer (very handy)
![Page 12: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/12.jpg)
DocumentationEasiest: Plug class name into favorite search engineFirst 1-2 results usually msdn.microsoft.com/…, which will be what you wantOnly rely on “core” classes being well-documented – everything else is pretty inconsistently documentedUse search engines to find examples – even VBScript examples can usually provide some help
Pipe retrieved WMI objects to Get-Member or to Format-List * in order to see what properties/methods they have, and what values the properties contain
![Page 13: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/13.jpg)
Exploring WMI
DEMO
![Page 14: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/14.jpg)
Using PowerShell LocallyUse Get-WmiObject cmdletCannot specify alternate credentials for local connections (by design); make sure shell is running as AdministratorSpecify –class name to query; retrieves all instances and all properties by default
![Page 15: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/15.jpg)
Filtering ResultsUse –filter parameter to narrow down instances returned (large result sets can take a lot of time and resources)-filter "property <comparison> value”
Numeric values are not delimitedString/date values are delimited in single quotesEasiest to enclose the entire filter in double quotes
Valid comparison operators:= > < <> <= => LIKE (use % as a wildcard)These are different from PowerShell’s native operators!
![Page 16: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/16.jpg)
WMI in PowerShell, Locally
DEMO
![Page 17: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/17.jpg)
Going RemoteUse –computerName parameter to specify remote computer(s)
-computername ”Client17”-computername (get-content names.txt)-computername “client17”,”client18”,”client19”
Other parameters allow specification of alternate credential-credential CONTOSO\AdministratorGraphically prompts for password – by designUse Get-Credential to create a reusable credential object that contains a password
![Page 18: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/18.jpg)
Multiple ComputersRemote connections are synchronous and sequential (not parallel)
Use –AsJob to run in backgroundUse remoting (Invoke-Command) for parallel processing (not in this session)
Failure of one computer will not stop the command from continuingYou can trap errors and log them; we’ll see how later
![Page 19: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/19.jpg)
WMI in PowerShell, Remotely
DEMO
![Page 20: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/20.jpg)
The StepsMove command into a “batch file” for easier repetitionEnclose command in a function for parameterization
Add error handling / loggingUpgrade function to a filtering function to accept pipeline input
Enables scenarios like getting names from AD OR a text fileUpgrade function to an advanced function (v2 only) for cmdlet-like behaviorPackage as a Script Module (v2 only) for easier distribution and re-use by othersAdd comment-based help so you can tell what the heck it’s doing
(I’ll demo – you remind me of what step is next)
![Page 21: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/21.jpg)
Building a WMI Tool
DEMO
Remember! I’ll save all my scripts and make them downloadable fromwww.ConcentratedTech.com in a few days – no need to take notes!
![Page 22: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/22.jpg)
ConclusionWMI + PowerShell = Very Powerful, Very ConvenientAnd a great way to learn PowerShell incrementally!Build reusable, cmdlet-like tools
Now in the TechEd Bookstore:Windows PowerShell v2: TFM by Don Jones & Jeffery Hicks
Download this session’s scripts & slides fromwww.ConcentratedTech.com
![Page 23: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/23.jpg)
Track Resources
Resource 1
Resource 2
Resource 3
Resource 4
![Page 24: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/24.jpg)
Resources
www.microsoft.com/teched
Sessions On-Demand & Community Microsoft Certification & Training Resources
Resources for IT Professionals Resources for Developers
www.microsoft.com/learning
http://microsoft.com/technet http://microsoft.com/msdn
Learning
![Page 25: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/25.jpg)
Related Content
Breakout Sessions (session codes and titles)
Interactive Sessions (session codes and titles)
Hands-on Labs (session codes and titles)
Product Demo Stations (demo station title and location)
![Page 26: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/26.jpg)
Complete an evaluation on CommNet and enter to win!
![Page 27: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/27.jpg)
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to
be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
![Page 28: Inventory your network and clients with PowerShell](https://reader033.vdocuments.us/reader033/viewer/2022061205/5480b2acb4af9f602c8b4572/html5/thumbnails/28.jpg)
This slide deck was used in one of our many conference presentations. We hope you enjoy it, and invite you to use it within your own organization however you like.
For more information on our company, including information on private classes and upcoming conference appearances, please visit our Web site,
www.ConcentratedTech.com.
For links to newly-posted decks, follow us on Twitter:@concentrateddon or @concentratdgreg
This work is copyright ©Concentrated Technology, LLC