Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

PowerShell for the Anxious ITPro

898 views

Published on

“What was wrong with my handy STSADM scripts?” “You mean there are things that I cannot do from the GUI now?” “WHAT THE HECK IS THIS VERB-NOUN STUFF?” If you have been thinking these or similar things about the new world order under a PowerShell driven regime, you are not alone. Come learn the basics and how to truly optimize your SharePoint implementation using this powerful ITPro toolset. You will walk away with a new a mind full of new ideas and a pocket full of scripts to get you started.

Published in: Technology
  • Be the first to comment

PowerShell for the Anxious ITPro

  1. 1. A Journey down the rabbit hole PowerShell for the Anxious ITPro: Jason Himmelstein, SharePoint MVP Office 365 Advisory Services Manager @sharepointlhorn http://www.sharepointlonghorn.com
  2. 2. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com Jason’s contact & vitals • SharePoint Server MVP • Office 365 Advisory Services Manager • SharePoint Community Leadership Board, Chair • Blog: www.sharepointlonghorn.com • Twitter: @sharepointlhorn • LinkedIn: www.linkedin.com/in/jasonhimmelstein • SlideShare: http://www.slideshare.net/jasonhimmelstein • Email: jase@sharepointlonghorn.com • Author of Developing Business Intelligence Apps for SharePoint – http://bit.ly/SharePointBI
  3. 3. If we are lucky, there *might* be a Big Seb sighting….
  4. 4. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • Introduction • What is it? • History • The Why • Core principles • Do's & Do not's • Practical application • Functional Explanation • Wrap up Agenda
  5. 5. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • Do as I say not as I do • Ask questions • Be patient! • Pray to the demo & Cloud gods Rules for today 
  6. 6. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • It isn't: – Fire and forget – A packaged executable – Developer-centric – Too hard for an ITPro • It is: – Command line environment – Microsoft technology holistic – A swiss army knife with a chain saw – The future of ITPro's world What is it?
  7. 7. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • Windows PowerShell is Microsoft's task automation framework, consisting of a command- line shell and associated scripting language built on .NET Framework. PowerShell provides full access to COM and WMI, enabling administrators to perform administrative tasks on both local and remote Windows systems. – Definition from Wikipedia • What is it really – PowerShell is an object-based, not text-based, command-line interface for Microsoft Technologies • What does that mean: –Results in PowerShell can be acted upon, not just read from What is it?
  8. 8. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • Started internally at Microsoft in 2002 • Demo'ed at PDC in 2003 - early stage • Private beta • Public Beta in June 2005 • April 2006 changed the name to PowerShell • PowerShell v1 for RTW on Nov 14 2006 • PowerShell v2 was released in Aug 2009 as a part of Win7 & Server 2008 R2 • PowerShell v3 was released as a part of Win8 & Server 2012 • PowerShell v4 is coming as a part of Server 2012 R2 History
  9. 9. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • Why did Microsoft create PowerShell & move more to a PowerShell world than a GUI world? • What is it used for: – Deployment – Configuration – Management – Administration – Development The Why
  10. 10. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com •The "hardware" • PowerShell Console vs PowerShell ISE •The terminology • Shell • Command-lets - "cmdlets" • Variables • Pipeline • Scripts • Functions • Modules The Basics
  11. 11. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • Main building block of PowerShell • Mini Commands that perform one action • Actually .NET Classes that can easily be created if new functionality is required • The output of one cmdlet can be piped into further cmdlets • Equality test with expressions such as –eq –lt –match cmdlets
  12. 12. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • Script – A script module is a file (.psm1) that contains any valid Windows PowerShell code. • Binary – A binary module is a .NET Framework assembly (.dll) that contains compiled code. • Manifest – A module manifest is a Windows PowerShell data file (.psd1) that describes the contents of a module and determines how a module is processed. • Dynamic – A dynamic module is a module that does not persist to disk. • created using New-Module, intended to be short-lived and cannot be accessed by Get- Module 12 Modules
  13. 13. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com •Instances of classes •Have properties and methods 13 Objects
  14. 14. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com •Properties and Methods of an object – Properties – what an object is – Methods – what you can do with the object 14 Members
  15. 15. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com •Chain of object processing •Output becomes input 15 PipeLine
  16. 16. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com •Get-verb – Gets approved Windows PowerShell verbs •Get-member – Listing the Properties and Methods of a Command or Object • •Get-history – If you didn’t start transcript, you can still review your history before closing your Shell or ISE window Functional Explanation
  17. 17. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com •Use variables •Only one thing at a time •Comment your scripts •Create scripts using an ISEIDE, execute in shell •Dispose of your objects code •Test before using in Production •Write re-usable scripts The Do’s
  18. 18. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • Vary your variables • Hard code your scripts • Take code from the internet or vendor & just RUN in your environment • Assume that code is not harmful… it is. • Run your code in an IDEISE and expect everything to work The Do Not’s
  19. 19. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • Comment – # • Add – + • Equal – = – -eq • Not Equal – ! – -ne – -not 19 PowerShell Syntax
  20. 20. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com •() – Curved brackets (Parenthesis) are used for required options, compulsory arguments, or control structures •{} – Curly brackets are used for block expression within a command block – Used to open a code block •[] – Square Brackets are used to denote optional elements or parameters – Also used for math functions 20 Bracketology
  21. 21. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com Simple Hard Demos
  22. 22. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • Why Run-As Administrator • How to configure icon settings 22 Run-as Administrator
  23. 23. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • Using PowerShell to add a server to a farm • Writing your own scripts using functions 23 Add-Server2Farm
  24. 24. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com 24 PowerShell vs PowerShell ISE
  25. 25. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • PowerShell vs PowerShell ISE • Methods – Start-transcript – PowerShell Profiles 25 Transcription
  26. 26. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com Creation script – New folders – New files • .ps1 • .bat – Adds content to files – Adds shortcut to the All Users Startup folder 26 PowerShell Profiles
  27. 27. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com Questions & Answers
  28. 28. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com • Jason’s info – http://www.sharepointlonghorn.com – jase@sharepointlonghorn.com – @sharepointlhorn • Seb Matthews – http://sebmatthews.net • Jason’s GitHub repo – http://www.github.com/jasonhimmelstein • The Scripting Guy – http://blogs.technet.com/b/heyscriptingguy/ Handy information
  29. 29. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com Blog: www.sharepointlonghorn.com Twitter: @sharepointlhorn LinkedIn: www.linkedin.com/in/jasonhimmelstein SlideShare: http://www.slideshare.net/jasonhimmelstein Email: jase@sharepointlonghorn.com me
  30. 30. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com Terms for you can Google with Bing later
  31. 31. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com •members •objects •pipelines •verb-noun •dot sourcing •parsing Core Principles
  32. 32. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com •Shell •cmdlets* •Blocks/regions •Scripts •Functions •Modules* •Profiles Core principles (i)
  33. 33. Rackspace Company Confidential. Distribution is in violation of any Non-Disclosure Agreement on File. www.rackspace.com •Objects* •Members* •Pipelines* •Verb-Noun •Dot sourcing •Parsing •Providers Core principles (ii)

×