Introduction to PowerShell - PowerPoint PPT Presentation

About This Presentation
Title:

Introduction to PowerShell

Description:

For each GUID found, Examine DisplayName searching for match of SQL Server' ... Professional Windows Powershell, Andrew Watt. Windows Powershell Cookbook, Lee Holmes ... – PowerPoint PPT presentation

Number of Views:6321
Avg rating:3.0/5.0
Slides: 19
Provided by: brianb94
Category:

less

Transcript and Presenter's Notes

Title: Introduction to PowerShell


1
Introduction to PowerShell
  • Brian Button
  • VP Engineering
  • Asynchrony Solutions, Inc
  • brian.button_at_asolutions.com
  • http//oneagilecoder.asolutions.com

2
Just the other day
Visual Studio 2005 Enterprise Library
VS.Net SP1 Nunit
IIS Xunit.net
TFS Explorer Resharper
SQL Server 2005 Test Driven.net
GAX
GAT
3
Failure!!!
  • SQL Server failed to install and uninstall
  • What to do???
  • MSDN says
  • Regedit HKLM\Software\Microsoft\Windows\CurrentVe
    rsion\Uninstall
  • For each GUID found, Examine DisplayName
    searching for match of SQL Server
  • Manually uninstall it
  • Maybe there was a better way!

4
What is PowerShell
  • New Scripting language
  • Same, but different!
  • In Vista, then unbundled
  • Separate download
  • General purpose programming language

5
Basic Tour
  • Shell prompt
  • Cmdlets
  • Pipes
  • .Net objects
  • PSDrives
  • Help system

6
5 key commands
  • Get-Help
  • Get-Command
  • Get-Member
  • Get-Psdrive
  • Format-List

7
Lets build something
  • Removing all bin and obj folders from project
  • Find all IDisposable classes in assembly

8
Powershell as a programming language
  • General purpose programming language
  • File extension PS1
  • Example Reformat.PS1

9
Extending Powershell
  • Custom Cmdlets and PSSnapins
  • Written in C or VB.Net
  • Functions, Filters, Aliases
  • Written in powershell
  • Adding methods, properties to existing types
  • Written in XML, powershell
  • Add-member

10
Extending Powershell in C/VB.Net
  • Create Custom cmdlet
  • Create PSSnapin to install
  • Great tutorial at http//blogs.msdn.com/daiken/arc
    hive/2007/02/07/creating-a-windows-powershell-cmdl
    et-using-the-visual-studio-windows-powershell-temp
    lates.aspx

Cmdlet(VerbsCommon.Get, "Proc") public class
GetProcCommand Cmdlet
11
Extending Powershell natively
  • Functions
  • function to_uppercase
  • param(stringfirst)
  • first.ToUpper()
  • At command line or in user profile

12
Extending Powershell natively
  • Aliases make commands easier to use
  • set-alias, new-alias, get-alias
  • Alias gal Get-Alias
  • Alias gc Get-Content
  • Alias gci Get-ChildItem
  • Alias gcm Get-Command
  • Alias gdr Get-PSDrive

13
Customizing Powershell
  • User profile
  • profile
  • Get-Executionpolicy
  • Like .profile or .login in Linux
  • Invoked for every new shell
  • Sets up functions, aliases, etc

14
Why learn Powershell
  • Automate repetitive tasks
  • Share knowledge with others
  • Its the Microsoft Way

15
Controlling Windows through Scripts
  • Complaints for years about GUI-only config
  • In Unix/Linux forever
  • MS making admin tasks powershell-scriptable
  • Exchange
  • SQL Server
  • IIS 7
  • More

16
Resources
  • Download powershell through Microsoft.com
  • Videos
  • http//channel9.msdn.com/Media/?TagID163
  • Blogs
  • http//blogs.msdn.com/powershell
  • http//thepowershellguy.com
  • http//keithhill.spaces.live.com
  • http//www.leeholmes.com/blog

17
More resources
  • Books
  • Powershell in Action, Bruce Payette
  • Professional Windows Powershell, Andrew Watt
  • Windows Powershell Cookbook, Lee Holmes
  • Community projects
  • 21 projects on http//www.codeplex.com

18
Q A
  • Slides posted at http//oneagilecoder.asolutions.c
    om
  • Email questions to brian.button_at_asolutions.com
Write a Comment
User Comments (0)
About PowerShow.com