Powershell Seminar @ ITWorx CuttingEdge Club

  • 2,535 views
Uploaded on

PowerShell Presentation conducted in ITWorx Cutting Edge Club 10-June-2008

PowerShell Presentation conducted in ITWorx Cutting Edge Club 10-June-2008

More in: Business , Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
No Downloads

Views

Total Views
2,535
On Slideshare
0
From Embeds
0
Number of Embeds
7

Actions

Shares
Downloads
145
Comments
0
Likes
3

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • INF210

Transcript

  • 1. Windows PowerShell The Next Generation Command Line Scripting Essam Salah Team Leader ITWorx http://esamsalah.blogspot.com/
  • 2. Agenda
    • Introduction
      • What is Windows PowerShell?
    • Using PowerShell
      • How can I script with Windows PowerShell?
    • PowerShell and .net
      • How .net developers will benefit from PowerShell
  • 3. Introduction What is PowerShell?
  • 4. What is PowerShell
    • Revolutionary new interactive shell and scripting language
      • Based on .NET
      • New set of built-in tools (+120)
      • Can continue to use current tools
      • Can continue to use current automation (COM)
      • Allows access to data stores as easy to access as file systems
  • 5. Why?
    • Try things out in an interactive shell
    • Stitch things together with utilities
    • Put the results in a script file
    • Generalize
    • Clean it up  production-quality
    • Be more Productive
    • Secure by default
  • 6. Where ?
    • Supported on Windows XP and above
    • Microsoft Products
      • Exchange 2007
      • System Center (Family) 2007
      • New Management Architecture based on PowerShell
      • Windows Server 2008
    • None Microsoft Products
      • IBM WebSphere MQ 6
      • VMWare InfrastructureToolkit
  • 7. MMC 3.0 Layered Over Windows PowerShell Command Line GUI Layered Over Your Application To Manage Windows PowerShell Engine Custom Application Microsoft Management Console 3.0 PSObject Windows PowerShell Cmdlets Windows Forms Early Bound Objects
  • 8. Using PowerShell
  • 9. How to start?
    • PowerShell is a free download from Microsoft
    • Separate download for each windows version
  • 10. Explore
    • Get-Help
    • Get-Command
      • > Get-Command i*
      • > Get-Command –Noun Process
    • Use Tab for Auto Complete
  • 11. The basics
      • Syntax: verb-noun –parameter arguments
      • Always singular, parameters starts with “ - ”
    • Examples:
      • > Get-Process –name ie*
      • > Get-Process ie*
      • > Get-Service
      • > Read-Host “Please Enter a number”
  • 12. The basics (cont’d)
    • You can alias
      • Set-Alias gps Get-Process
    • Parameters can be positional
      • gps –ProcessName w3wp
      • gps w3wp
    • Many parameters can be wildcarded
      • gps c*
    • Partial parameter names allowed
      • Gps –p w3wp
  • 13. Trusting Operations
    • Commands with side-effects support:
      • Whatif
        • Stop-Service win* –WhatIf
      • Confirm
        • Stop-process S* -Confirm
      • Verbose
  • 14. Security is key for PowerShell
    • By default, only interactive usage allowed
    • If you want to use scripting, you need to change the ExecutionPolicy
    • Get-ExecutionPolicy / Set-ExecutionPolicy
    • PS1 files opened with Notepad by design
  • 15. Finding Data in Data Stores
    • Data stores surfaced as “Drives”
      • Filesystem, Registry, Alias, Certs, Env, Functions, Variables, etc.
      • > Get-PSDrive
      • > dir HKLM:SOFTWAREMicrosoft
    • Rich common semantics
      • > Dir logs –Include *.txt –Exclude A* -Recurse
    • Tab-Completion in all Drives
      • > Dir HKLM:So<TAB>Mi<TAB> => HLKM:SoftwareMicrosoft
    • Demo 1 : File System Navigation
    • Demo 2 : Registry Navigation
    • Demo 3 : Environment Variables Navigation
  • 16. Working with objects
    • .NET
      • All classes from .net framework
    • WMI
      • Access to your whole system and remote systems, too
    • COM
      • Microsoft Office Applications
      • ActiveX controls
  • 17. PowerShell and COM
    • Demo 1
      • Using the Speech Class in Windows Vista
    • Demo 2
      • Using Excel to list all services in the machine
  • 18. PowerShell and WMI
    • WMI
      • Windows Management Instrumentation
      • A way for System components to provide information and notification
    • Demo
      • Using WMI to get Physical Memory Size
    • WMI Providers exist for most of Microsoft Products :
      • SQL Server, BizTalk , CRM , SharePoint …
  • 19. Commands Emit Objects
    • Traditional text parsing replaced with direct object manipulation
    • A default text view of objects is dynamically computed
      • Table for objects with < 5 properties
      • List for objects with 5 or more properties
  • 20. Explicit Object Formatting
    • Built-in formatters for lists, tables, wide, and custom-views
      • > Get-Command Format-*
    • Formatters allow you to specify properties, propertysets and property expressions
      • > gps |format-table name,id,handlecount
      • > gps |format-table name,@{ Expression= {$_.mainmodule.filename}; Label=&quot;File&quot;}
      • > gps |format-list name,*size64
  • 21. Object Utilities
    • Group
      • > gps |group Company
    • Select
      • > gps |Select name,id
      • > gps |Select –first 10
    • Where > gps |where {$_.handles –ge 500}
    • Sort
    • >Get-EventLog System -Newest 100 | group Source | sort count
  • 22. Uniform Data Access Syntax
    • Provides a common user interface to objects of different type systems
    • XML
      • > $x=[xml]&quot;<a><b><c>TEST</c></b></a>&quot;
      • > $x.a.b.c
    • No more Property bags
      • $x.Handles vs. $x.Properties[“Handles”]
  • 23. PowerShell Extensions
    • 40+ Project for PowerShell on CodePlex
    • PowerTab
    • Power Gadget [DEMO]
    • PowerShell Reflactor Add-in
    • PowerShell Community Extensions
    • PowerShell Remoting
    • Providers
      • PowerShell Windows Mobile Provider
      • PowerShell SharePoint Provider
      • PowerShell SQL Server Analysis Services Provider
      • PowerShell BizTalk Provider
  • 24. PowerShell & .net
  • 25. PowerShell is based on .net
    • Everything in PowerShell is a .net object
    • Reflection is every where
    • > (Get-Process)[0] | Get-Member
  • 26. Scripting with .net classes
    • Any .net class ca be used
    • Example
    $query = &quot;SELECT * FROM [Customers]“ $connString = &quot;server=.;integrated security;database=northwind“ $dataset = new-object &quot;System.Data.DataSet&quot; &quot;MyDataSet“ $da = new-object &quot;System.Data.SqlClient.SqlDataAdapter&quot; ($query, $connString) $da.Fill($dataset)
  • 27. Develop your own Cmdlets
    • Visual Studio Template for PowerShell
  • 28. Call PowerShell Cmdlet from .net
  • 29. Call PowerShell Cmdlet from .net
  • 30. Q & A
  • 31. Resources Technical Chats and Webcasts http://www.microsoft.com/communities/chats/default.mspx http://www.microsoft.com/usa/webcasts/default.asp Microsoft Learning and Certification http://www.microsoft.com/learning/default.mspx MSDN & TechNet http://microsoft.com/msdn http://microsoft.com/technet Virtual Labs http://www.microsoft.com/technet/traincert/virtuallab/rms.mspx Newsgroups http://communities2.microsoft.com/ communities/newsgroups/en-us/default.aspx Technical Community Sites http://www.microsoft.com/communities/default.mspx User Groups http://www.microsoft.com/communities/usergroups/default.mspx