Presentation is loading. Please wait.

Presentation is loading. Please wait.

James Boother Blog: INTRODUCTION TO POWERSHELL.

Similar presentations


Presentation on theme: "James Boother Blog: INTRODUCTION TO POWERSHELL."— Presentation transcript:

1 James Boother Email: james@boother.co.uk Twitter: @jimmyboo Blog: http://www.boother.co.uk INTRODUCTION TO POWERSHELL

2 AGENDA A brief history lesson Don’t be scared everything’s familiar What’s new in 2.0? Scripting IDE’s Profiles Cmdlets and Variables Providers Resources

3 IN THE BEGINNING…

4 AFTER YEARS OF RESEARCH POSH WAS BORN

5 HOW DO I GET POWERSHELL INSTALLED? PowerShell 2 Pre-Installed on Windows 7 and Windows Server 2008 R2 Can be installed on Windows XP and Windows Server 2003 & 2008 Download from http://support.microsoft.com/kb/968929 - Windows Management Frameworkhttp://support.microsoft.com/kb/968929

6 YOU CAN USE FAMILIAR COMMANDS Demo

7 WHAT’S NEW IN VERSION 2? Remoting Integrated Scripting Environment Modules Advanced functions Background jobs Eventing Script internationalisation Script debugging New cmdlets

8 SCRIPTING IDES Notepad++ Microsoft’s Interactive Scripting Environment (Part of PowerShell 2) PowerGui Visual Studio VSX – Adam Driscoll

9 NOTEPAD ++

10 MSFT INTERACTIVE SCRIPTING ENVIRONMENT

11 POWERGUI.ORG

12 VISUAL STUDIO VSX

13 GETTING HELP Get-Help commandlet F1 in ISE Autocomplete in PowerGui & VSX Visual Search on Bing

14 POWERSHELL PROFILES A PowerShell script that is run by the PowerShell host on launch I’ve created a global profile to be run by all users and all hosts Create C:\Windows\System32\WindowsPowerShell\v1.0\profile.ps1 Why? Add Visual Studio Environment Variables Add SQL Server Environment Variables Load Dlls into memory

15 CMDLETS Main building block of PowerShell Scripts Mini Commands that perform one action Common naming convention: Verb then Noun e.g.: Get-Help, Get-Object, Remove-Item Actually.NET Classes that can easily be created if new functionality is required The output of one Cmdlet can be piped into further cmdlets using the | operator Destructive CmdLets have –WhatIf parameter

16 REALTIME LOG FILE MONITORING Demo

17 VARIABLES Defined by a name prceeded by a dollar sign (“$”) When working in the pipeline (“$_”) is the current item A single equals character is used for assignment e.g. $a = 1 or $a = $b Equality test with expressions such as –eq –ne –gt –ge –lt –le –like –and -or Strings in double quotes automatically replace variables with their value. To prevent this from happening use single quotes ‘Some test $no replacement here” If you want to include carriage returns format your string like this @”…”@

18 PROVIDERS Providers are.net libraries. The SQL Server team created a provider ProviderDescription Alias ProviderProvides access to the Windows PowerShell aliases and their values Certificate ProviderProvides read-only access to X509 certificate stores and certificates Environment ProviderProvides access to the Windows environment variables FileSystem ProviderProvides access to files and directories Function ProviderProvides access to the functions defined in Windows PowerShell Registry ProviderProvides access to the system registry keys and values Variable ProviderProvides access to Windows PowerShell variables and their values WSMan ProviderProvides access to WSMan configuration information

19 NAVIGATING A DATABASE WITH SQL PROVIDER Demo

20 WMI SCRIPT Full access to WMI from within Powershell:

21 DELETING OLD BACKUP FILES

22 A FEW SQL MAINTENANCE SCRIPTS

23 SCHEDULING SCRIPTS SQL Server Agent or windows Task Scheduler

24 SUMMARY Powerful object based scripting engine Backwards compatible so you can start from what you already know Full access to File System; Registry; WMI; COM;.NET Objects and SQL Server Simple to schedule using Windows Scheduled Tasks or SQL Jobs Extensible through.NET

25 WEB RESOURCES Master-PowerShell | With Dr Tobias Weltner http://powershell.com/cs/blogs/ebook/default.aspx The Scripting Centre http://technet.microsoft.com/en-gb/scriptcenter/dd742419.aspx PowerShell owners manual http://technet.microsoft.com/en-us/library/ee221100.aspx PowerShell team blog http://blogs.msdn.com/b/powershell/ Adam Driscoll – Visual Studio PowerGUI VSX - http://visualstudiogallery.msdn.microsoft.com/01516103-d487-4a7e-bb40-c15ec709afa3/ Setting SQL Environment Variables http://sqlblogcasts.com/blogs/martinbell/archive/2009/09/06/Using-SQL-Server-in- Powershell-outside-of-SQLPS.aspx

26 BOOKS

27 QUESTIONS If you have any questions now’s your chance…

28 THANK YOU Thank you for attending Automating admin tasks with PowerShell if you have any further questions please see my contact details here: Email: james@boother.co.uk Twitter: @jimmyboo Blog: http://www.boother.co.uk Happy scripting!


Download ppt "James Boother Blog: INTRODUCTION TO POWERSHELL."

Similar presentations


Ads by Google