1 / 23

How to use PowerShell in PAREXEL environment

How to use PowerShell in PAREXEL environment. December, 21, 2010. Bartek Bielawski Sr IT Site Services Specialist Warsaw, Poland. PART I: BASICS. What is PowerShell and how can I get it?. PowerShell IS: Automation engine Scripting language Interactive console To use it:

nubia
Download Presentation

How to use PowerShell in PAREXEL environment

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How to use PowerShell in PAREXEL environment December, 21, 2010 Bartek Bielawski Sr IT Site Services Specialist Warsaw, Poland

  2. PART I: BASICS

  3. What is PowerShell and how can I get it? • PowerShell IS: • Automation engine • Scripting language • Interactive console • To use it: • Windows 7/ Windows Server 2008 R2 • Windows XP + Windows Management Framework • How pretty it can be? • PowerShell.exe – cmd.exe revisited • PowerShell ISE – notepad.exe on steroids • PowerGUI – MMC + brilliant editor (3rd party)

  4. Hosts Demo • PowerShell.exe/ PowerShell ISE/ PowerGUI + PowerGUI editor

  5. Switch from cmd.exe or *nix shell • Easy switch: • Cmd.exe – just launch powershell instead • Aliases/ functions to make it easier for us • *nix have their set of aliases too • ‘Old’ commands still work!

  6. Verb-Noun to guess command • Discover: • Get-Verb + Guess Noun • Syntax almost like sentence: • Get-Process | Where { $_.WorkingSet –gt 100MB } | Stop-Process -Whatif • Meaningful parameters • disambiguate it • Tab Completion

  7. Objects - what they are? How to use Methods How to use Parts Parts Properties Pedal Front Wheel Steer Left Back Wheel Steer Right Pedals Apply Front Brake Saddle Apply Rear Brake Frame

  8. Objects – what they are in ‘Our’ world? How to use Methods Parts Properties Stop() DisplayName Start() Status Pause() RequiredServices Windows Service

  9. Objects all around • PowerShell objects: • Microsoft.NET objects • COM objects • WMI Objects • AD Objects • Variables • Single ver. Array • Foreach as a key to collection • Tab to help us see interior • Methods definitions using name without ()

  10. Pipeline Get-Process | Where { $_.handles –gt 500 } | Sort handles | Format-Table Common Windows PowerShell Parser Get-ProcessCmdlet Sort Cmdlet FormatCmdlet Where Cmdlet Windows PowerShell Pipeline Processor

  11. PART II: Three cmdletsto start with

  12. Get-Command to know what to look for • What it can do for me? • List commands (functions, aliases, cmdlets, ‘legacy’ commands) • Show definition • Show parameters • How I can use it? • New module – what does it contain? • Bell rings – what was this cmdlet name? • I know Verbs, I know Nouns, need command!

  13. Get-Helpask PowerShell first • Easy: My-Command -? • Basic description • Definition to know parameter names • Related links to dig more • Everything: Get-Help My-Command -full • Tons of info • Examples • Parameters descriptions • Parts: -Examples, -Parameter My-Parameter • Examples to try and learn • Parameter description to understand what I need to get my results

  14. Get-Memberobjectsunder the lens • Too many objects • Hard to remember properties/ method names • Even harder to know how to use those • Useful to see what’s inside • Common usecases: • COM objects (Excel.Application) • To see if we got what we expected • To get static methods of .NET classes • Why? • Helps when interactive • We save our memory • Can discover not documented objects

  15. PART III: Technologiesto use it with

  16. WMI • WMI? • MS implementation of CIM • Lot of information about hardware/ software and more • Available using RPC • Why? • Inventory • Ad-hoc administration (services, processes, and God-knows-what) • How? • Get-WMIObject (alias gwmi) • Invoke-WmiMethod (alias iwmi) • -List to list, asterisk to list more… • Demo

  17. AD • Quest – 3rd party • Very easy, very handy • Requires install on our box • Demo • MS ActiveDirectory module • Not as easy • Currently only W7 or W2k8 R2 (using RSAT)

  18. Files, registry, event logs… • PSProviders and PSDrives • (Almost) everything is a drive • Browse registry as file system • Wonderful asterisk support • Quick ways to filter stuff • *-EventLog • Get, Limit – both local and remote • Great for quick look and decent reports • *.log • Select-string and regular expressions

  19. What else? • VMWare • NetApp • Exchange • SharePoint • SQL • IIS • SCCM • .. And more to come! ;)

  20. PART IV: Practice

  21. To be on the safe side… • Check it first • What if? • Please ask me to confirm… • Build from floor to roof • First get, then filter, than format/ output/ set • Check each step as you go • -WhatIf or –Confirm to avoid problems • Save good lines and reuse them later

  22. Help! • Forums • TechNet • PowerShellCommunity.org • Twitter • Tag #PowerShell • Enjoy and learn, or opposite ;) • On your own • Free eBooks (Master PowerShell, PowerShell TFM 2nd ed, and others) • Ask PowerShell (Get-Help, -Online, F1 in PowerShell ISE) • Blogs, blogs, blogs • Podcasts (PowerScripting Podcast, Get-Scripting Podcast)

  23. Q & A

More Related