No-script PowerShell v2

download No-script PowerShell v2

If you can't read please download the document

  • date post

    02-Nov-2014
  • Category

    Technology

  • view

    5
  • download

    0

Embed Size (px)

description

 

Transcript of No-script PowerShell v2

  • 1. The Windows PowerShell v2 No-Scripting Crash Course Don Jones ConcentratedTech.com Pre-requisites for this presentation:1) Strong understanding of basic Windows administration Level:Intermediate

2. 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 3. About the Instructor

  • Don Jones
  • Contributing Editor,technetmagazine.com
  • IT author, consultant, and speaker
  • Co-founder of Concentrated Technology
  • Seven-time recipient of Microsoft s Most Valuable Professional (MVP) Award
  • Author and Editor-in-Chief for Realtime Publishers
  • Trainer for www.CBTNuggets.com

4. Notes

  • Sample Code
    • I ll save as I go
    • I ll make everything available as a download from my Web site details on the last slide
    • I ll also include a copy of this slide deck
    • Please personal use only.
  • Agenda
    • This deck is really just a guide to make sure you have certain things in writing to take home
    • We might change up the order a bit, and you ll see a lot more than I list here

5. The Agenda

  • PowerShell backgrounder and crash course
  • Accomplishing real IT admin tasks using PowerShell

6. Resources

  • ConcentratedTech.com New tech contentevery day(including PowerShell tips & series)
  • PowerGUI.org
  • PowerShell.com / Idera.com
  • PrimalScript.com
  • Blogs.Msdn.Com/PowerShell

7. If you re following along

  • Start-Transcriptfilename
    • Records a transcript of everything you type in the shell, including output
    • Helps create a log of what you do here in class
    • Simple text file
  • Stop-Transcript

8. What is Windows PowerShell?

  • A command-line interface (CLI) used to administer Windows and other products and technologies
  • but also a new way of developing Windows and other products to be more manageable
  • Aninteractiveshellas well asa simplified scripting language

9. Why a CLI?

  • A GUI is great for creatingoneuser, or modifyingoneserver, or reconfiguringoneservice
  • Performing anything multiple times in a GUI becomes repetitive, boring, and error-prone
  • A CLI is inherently better when it comes to automating repetitive tasks

10. But the GUI can do mass administration!

  • Tools (often third party) can be written to perform specific repetitive tasks
  • do you want to spend all your time hunting down, learning, and possibly paying for dozens ofpoint solution tools?
  • A CLI provides asingle wayto do it all, in a consistent fashion

11. The Dark Ages of Administration Windows / Server Product Functionality (Services, Configuration Database, etc) Graphical User Interface for Administration (MMC Snap-Ins) COM Objects (DLLs) Command-Line Utilities WMI Provider Scripts (Batch, VBScript, etc.) The Missing Pieces 12. The Dark Ages Problem

  • Some command-line tools do some things
  • Some COM objects do some things
  • Some WMI providers do some things
  • Nothingdoeseverything !
  • Means learning many different tools, which all work differently

13. The PowerShell Age of Administration Windows / Server Product Functionality (Services, Configuration Database, etc) Microsoft .NET Framework Windows PowerShell Scripts GUI 14. The PowerShell Advantage

  • Bringall functionalitytogether in a single place (the CLI)
  • Expose the functionality in a way which can be automated (scripting)andused topower a GUI
  • Create that functionality in a consistent fashion (e.g., learnoneway to doeverything )

15. How it Happens

  • Microsoft builds new products so that their administrative functionalitylives in PowerShell
  • GUI consoles justsit on top of PowerShell
  • Over time, more and more products becomefully exposed in PowerShell

16. Fully PowerShell-ed Products

  • Exchange Server 2007
  • System Center Operations Manager 2007
  • System Center Virtual Machine Manager
  • System Center Data Protection Manager
  • More coming including non-Microsoft products!
  • Win2008 R2 addssignificantlyto the list

17. In the Meantime

  • PowerShell still connects toexistingadministrative functionality
    • Windows Management Instrumentation
    • Microsoft .NET Framework
    • Component Object Model (COM)
    • Active Directory Services Interface (ADSI)
  • Allows you to (partially) administer non-PowerShell technologiestoday

18. System Requirements

  • Windows XP or later (ships with Windows Server 2008 as anoptionalcomponent; installed by default in 2008R2 and Win7)
  • Microsoft .NET Framework v2.0 or later
  • Installeverywhere(remote shell!)

19. Installing PowerShell

  • Download from www.Microsoft.com/PowerShell (if not included with your version of Windows)
  • Run installer
  • Installs tosystemroot WindowsPowerShell

20. How it Works - Overview

  • Cmdletsare thecommand-line utilities within PowerShell
  • They work withobjects,not text, and canplug into one another to perform more complex tasks
  • Nicknames calledaliasesmake cmdlet names easier to type
  • Cmdlets can besnapped in to extend the shells functionality

21. Navigating your system

  • You probably already know how to do this!
  • Start thinking of the commands you'd use to navigate your system using Cmd.exe
  • Or, if you prefer the commands you'd use in a Linux or Unix operating system
  • Quiz follows

22. Same command different parameters

  • TryDir /s
  • Doesn't work!
  • Thecommand namesare similar to what you're used to in Cmd.exe
  • but the way in which the commands work are significantly different
  • Fortunately, PowerShell can help you learn how to use the new commands

23. Asking for help

  • PowerShell includes a robust built-in help system
  • Ask for help on any command using theHelpkeyword (orManif you prefer)
  • Helpaccepts wildcards lets you look up commands when you're not sure of their name
  • Provides a quick reference to the correct parameters and syntax
  • Addonlinefor latest version of help files

24. Single, consistent skill set

  • If you know one set of commands to navigate one type of hierarchical file system
  • why not use the commands for other types of storage systems?
    • The registry
    • The certificate store
    • Environment variables
    • Active Directory

25. How it works

  • PowerShell usesPSDrive Providersto connect to various storage systems
  • The providersadapta storage system to look like a "disk drive"
  • The providers translate commands like CD and DIR into whatever the underlying store needs to see

26. Just a few changes

  • PowerShell does have a few quirks when compared to Cmd.exe
    • Cd .. , notCd..(needs the space)
    • Cd "Program Files"notCd Program Files(paths with spaces need to be in quotes)
    • Etc.
  • You usually get used to these minor changes pretty quickly

27. You've already used cmdlets!

  • Cd, Ls, Dir, Copy, and Cp are allcmdlets(pronounced "command-lets")
  • Technically, these arealiases,or nicknames, to actual cmdlets
  • Cmdlets are written in a .NET Framework language
  • Cmdlets are bundled into DLL files calledsnap-insorPSSnapIns

28. Aliases

  • Aliases are just "short names" for cmdlets
  • They're easier to type
  • They provide consistency with old-style command names
  • Many aliases come built in, and you can create your own

29. That's whydir /sdoesn't work

  • Diris an alias forGet-ChildItem
  • The alias only covers the cmdlet name it doesn't change the parame