SlideShare a Scribd company logo
Boulos Dib
September 21, 2011
   Independent Consultant – Napeague Inc.
   Software Development since 1983
   Few Facts (@boulosdib)
     First Personal Computer 1980 – TRS-80 III
     First Z80 based product (EPROM based Protocol Adpator – 1984)
     First Commercial PC-DOS product (Telex on PCs – 1985)
     Started 16-bit Windows Development using Win 3.1
     Developed on: 8080/Z80, 68xxx, PDP/RSX,VAX-VMS and x86/x64
      (C/C++/C#)
     Worked with PowerShell since Monad (2006)
     Worked with SharePoint since STS (2003)
     More facts
      ▪ Favorite sport – Windsurfing 
      ▪ Favorite hobby – Playing my sunburst Fender Stratocaster+ guitar.
      ▪ Favorite guitar players
         ▪ Wes Montgomery, Larry Carlton and Ritchie Blackmore (Deep Purple, Rainbow)
   Overview of PowerShell
   Introduction to PowerShell Scripting
    Language
   Tools
   Script Authoring
   SharePoint Management Console
   SharePoint CmdLets
   NYC Code Camp
     I will be presenting on LightSwitch and Silverlight
        at the NYC Code Camp 6 (Autumn 2011)
       Saturday October 1st
       Pace University
       Registration Still Open
       http://CodeCampNyc.org
   Interactive Command Shell
   Programmatic (Script) Execution
    Environment
   Dynamic Scripting Language
   Extensible (CmdLets, .Net etc…)
   Hosted (i.e. NuGet)
   Management tool for Servers
“A shell is the piece of software that lets you access the
functionality provided by the operating system. “
Bruce Payette - Co-Designer and Implementer of the
PowerShell language.
   Example
       Windows Explorer
       Command.com
       Cmd.exe
       Bash (Unix)
       PowerShell
   Interactive Environment with .Net
   Automation Tool
   Easy to use
   Available on all Windows SKUs starting with
    XP SP2 and Windows 2003
   Management tool for Servers

   Productivity Gains – One Liner
Source:Wikipedia
   Common Parameters
       -Verbose
       -Debug
       -WarningAction
       -WarningVariable
       -ErrorAction
       -ErrorVariable
       -OutVariable
       -OutBuffer

   Risk Mitigation Parameters (certainly critical in a production environment)
       What-If
       -Confirm

   Wildcard support.
       All names and parameter value can support wildcard.
   Pipeline
       Much more about this later.
   Command vs. Expression mode parsing
     Echo 1+1
     1+1
   Everything returns a value
     “String”
   Variable
     $ Prefix
     i.e. $var = “Hello Sharepoint”
   Type System
     All .Net types as well as Custom Types
   Help
   Get-Help (or -? Following any command)
   Get-Help about_<<anyname>>
   Get-Help –Examples
   Get-Help –Full
   High level task oriented abstraction
   Verb-XXNoun
     Verbs: Get, Set, New, Write, Read
     Nouns: Drive, Variable, Provider, Site, Collection
   Get-Verb
   Predefined Commands
   When Starting Remember these:
     Get-Help
     Get-Member
     Get-Command
   Get-Help
     As it says, it helps!!!
   Get-Command
     Get information about what can be invoked
   Get-Member
     Show what can be done with an object
   Get-Module
     Show packages of commands
   GetType
     Discover details about an object’s type information.
   Compare
   Foreach
   Group
   Measure
   Select
   Sort
   Tee
   Where
   PowerShell ISE
     Simple Editor and Debugger
   PowerGUI
     Administrative Console
     PowerGUI Editor
     Powerpacks – a number to choose from.
   Visual Studio
   Notepad
   Out-Host
   Out-Null
   Out-Printer
   Out-String
   Out-GridView
   The best part about PowerShell
     Output of one CmdLet is Input into next CmdLet
      in pipeline.
     Uses the Pipe operator |
     Output and Input are objects, not text like
      traditional shells.
     Example
      ▪ Get-Command | Get-Member
      ▪ Get-Process | Out-GridView
   Case-Insensitive
   Variables: begin with $ (i.e. $a = “test”)
   Script Blocks using {}
   Array $a = 1,2,3
     $a[1]
   Hashtable
     $h = @{a=1; b=2}
   Scope – Functions and Script Blocks
   Security Context aware
   Remoting - WSMan
   If then else
     If ($a –eq “test”) { “It’s a test”} else {“Not”}
   While loop and Do While loop
     $i = 1; While ($i –lt 10) {$i++}
     $i =5; do {$i} while (--$i)
   For loop
     for ($i=0; $i –lt 10; $i++) { “5 * $i is $(5 * $i)” }
   Foreach loop
     Foreach ($i in 1..10) {“`$i is $i”}
   Foreach CmdLet
     1..10 | ForEach-Object {“begin”} {$_ * 2} {“end”}
   Where Cmdlet
     1..10 | Where-Object {$_ -gt 4 -and $_ -lt 10}
   Arithmetic Operators
     +*-/%
   Assignment Operators
     =, +=, -=, *=, /=, %=
   Get-Location and SetLocation
   Copy-Item
   Remove-Item
   Move-Item
   Rename-Item
   Set-Item
   New-Item
   Get-Content
   Pretty much the same as CMD
     > replace file
     >> Append to file
     2> File is replaced with error messages
     2>> Error text is appended to file
     2>&1 Error messages are written to output pipe
   A module is a package that contains Windows
    PowerShell commands, such as cmdlets,
    providers, functions, variables, and aliases
   Need to create module folder
     new-item -type directory -path
     $homeDocumentsWindowsPowerShell
     Modules
   Copy the module to the Modules folder.
   Start using a module (import-module etc…)
   Standard Providers
     Windows PowerShell providers are Microsoft .NET Framework-based
        programs that make the data in a specialized data store available in
        Windows PowerShell so that you can view and manage it

   Get-PSProvider | Select -Property Name
       WSMan -
       Alias
       Environment
       FileSystem
       Function
       Registry
       Variable
       Certificate
   Get-PSDrive
   New-PSDrive
     New-PSDrive -Name Y -PSProvider
      FileSystem -Root c:temp
   Remove-PSDrive
     Remove-PSDrive
   Try a non-disk PSDrive like cert: Dir Cert:
 A Script file is a text file with .ps1 extension
  containing one or more PowerShell command
 A Script is a simple mechanism to re-use
  functionality.
 To run a script on a remote computer, use the
  Invoke-Command and provide remote computer
  name as a parameter.
 Scripts can accept parameters.
 To run a script in the current session, we Dot-
  Source the . .Script1.ps1
 We can Scope Local or Global.
   Single Line: #
   Multi Line:
     <#
     #>


   Comments can be used to automatically
    generate help
   A function is a script block containing list of
    statements
   function small_files ($size = 1kB) {
       Get-ChildItem c:Temp | where { $_.length -lt $size -and
    !$_.PSIsContainer}
   }
   small_files
   To control how a function uses the pipeline, you
    use Begin, Process and End.
   function pipelineFunc {
       process {"The value is: $_"}
    }
    1,2,3 | pipelineFunc
   Advanced functions allow you to write CmdLets
    using scripts instead of compiled code.
   try
   {
         $wc = new-object System.Net.WebClient
         $wc.DownloadFile("http://www.contoso.com/MyDoc.doc","c:MyDoc.doc")
   }
   catch [System.Net.WebException],[System.IO.IOException]
   {
       "unable to download MyDoc.doc from http://www.contoso.com."
   }
   catch
   {
       "An error occurred that could not be resolved."
   }
      Sharepoint Management Shell
      Need to execute Add-SPShellAdmin in order
       to acquire permissions to run PowerShell on
       Sharepoint

                                                             Member of Farm
                               Member of Administrators
Farm component                                               Administrators SharePoint   Full Control on backup folder
                               group on the local computer
                                                             group
Farm                           Yes                           No                          Yes
Service application            Yes                           No                          Yes
Content database               Yes                           No                          Yes
Site collection                No                            Yes                         Yes
Site, list, document library   Yes                           No                          Yes

Source: MSDN
   Get-Command -Noun SP*
   (Get-Command –Name *-SP* -
    CommandType cmdLet).Count
    $Host.Runspace.ThreadOptions =
    "ReuseThread"

   Get-SPAssignment –Global
     $spWeb = Get-SPWeb -Identity $url
     $spWeb.TreeViewEnabled = $True
     $spWeb.Update()
   Stop-SPAssignment –Global
   Windows Powershell Blog
     http://blogs.msdn.com/b/powershell/
   Doug Finke – MVP (Also ShowUI)
     http://dougfinke.com/blog/
   PowerShell Magazine
     http://www.powershellmagazine.com/
   Jim Christopher MVP (Check out StudioShell)
     http://www.beefycode.com/
   Tome Tanasovski MVP/Author – NYC PowerShell
    User Group
     http://powertoe.wordpress.com/
   Productivity
     PowerGUI
      http://PowerGUI.org
     PowerTab
      http://powertab.codeplex.com/
     Community Extensions
      http://pscx.codeplex.com
     Quest ActiveRoles Management Shell
      http://www.quest.com/powershell/activeroles-server.aspx

   UI
     ShowUI (WPF) – http://showui.codeplex.com
Tool                             Url
PowerGUI                         http://PowerGUI.org/
PowerTab                         http://powertab.codeplex.com/
Community Extensions             http://pscx.codeplex.com/
Quest ActiveRoles                http://www.quest.com/powershell/activeroles-
                                 server.aspx/
ShowUI                           http://showui.codeplex.com/
Windows Automation Snaping for   http://wasp.codeplex.com/
Powershell
   NuGet
     http://nuget.org/
     http://nuget.codeplex.com/


   StudioShell
     http://studioshell.codeplex.com/
   PowerShell in Action                 Windows PowerShell 2.0 Bible
   Bruce Payette                        By Thomas Lee, Karl Mitschke, Mark
   “The book from the authority on       E. Schill, and Tome Tanasovski
    PowerShell”                          http://powertoe.wordpress.com/
   Automating Microsoft SharePoint          PowerShell for Microsoft Sharepoint
    2010 Administration with Windows          2010 Administrators.
    PowerShell 2.0
   Gary Lapointe & Shannon Bray           Niklas Goude & Mattias Karlsson
   http://blog.falchionconsulting.com/    http://www.powershell.nu/
   Next session will be about PowerShell Scripts
    in the SharePoint Management Shell

   Contact:
     http://blog.boulosdib.com
     @boulosdib

More Related Content

What's hot

Introduction To Power Shell
Introduction To Power ShellIntroduction To Power Shell
Introduction To Power Shell
Ivan Suhinin
 
PowerShell: Automation for Everyone
PowerShell: Automation for EveryonePowerShell: Automation for Everyone
PowerShell: Automation for Everyone
Intergen
 
PowerShell UIAtomation
PowerShell UIAtomationPowerShell UIAtomation
PowerShell UIAtomation
Juraj Michálek
 
Powershell Training
Powershell TrainingPowershell Training
Powershell TrainingFahad Noaman
 
Weblogic application server
Weblogic application serverWeblogic application server
Weblogic application server
Anuj Tomar
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
sudhir singh yadav
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
Ashrith Mekala
 
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
SlideTeam
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
Rayed Alrashed
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
Mehmet Ali Aydın
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
Qspiders - Software Testing Training Institute
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
Yashar Esmaildokht
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
Vibrant Technologies & Computers
 
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
Simplilearn
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
Khizer Naeem
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
Chandan Kumar Rana
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
John Lynch
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with Ansible
Ivan Serdyuk
 
DevOps Meetup ansible
DevOps Meetup   ansibleDevOps Meetup   ansible
DevOps Meetup ansible
sriram_rajan
 

What's hot (20)

Introduction To Power Shell
Introduction To Power ShellIntroduction To Power Shell
Introduction To Power Shell
 
PowerShell: Automation for Everyone
PowerShell: Automation for EveryonePowerShell: Automation for Everyone
PowerShell: Automation for Everyone
 
PowerShell UIAtomation
PowerShell UIAtomationPowerShell UIAtomation
PowerShell UIAtomation
 
Powershell Training
Powershell TrainingPowershell Training
Powershell Training
 
Weblogic application server
Weblogic application serverWeblogic application server
Weblogic application server
 
Complete Guide for Linux shell programming
Complete Guide for Linux shell programmingComplete Guide for Linux shell programming
Complete Guide for Linux shell programming
 
Shell scripting
Shell scriptingShell scripting
Shell scripting
 
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...Hands On Introduction To Ansible Configuration Management With Ansible Comple...
Hands On Introduction To Ansible Configuration Management With Ansible Comple...
 
IT Automation with Ansible
IT Automation with AnsibleIT Automation with Ansible
IT Automation with Ansible
 
Ansible - Hands on Training
Ansible - Hands on TrainingAnsible - Hands on Training
Ansible - Hands on Training
 
QSpiders - Automation using Selenium
QSpiders - Automation using SeleniumQSpiders - Automation using Selenium
QSpiders - Automation using Selenium
 
ansible why ?
ansible why ?ansible why ?
ansible why ?
 
PHP - Introduction to PHP Fundamentals
PHP -  Introduction to PHP FundamentalsPHP -  Introduction to PHP Fundamentals
PHP - Introduction to PHP Fundamentals
 
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
What Is Ansible? | How Ansible Works? | Ansible Tutorial For Beginners | DevO...
 
Automation with ansible
Automation with ansibleAutomation with ansible
Automation with ansible
 
Basics of shell programming
Basics of shell programmingBasics of shell programming
Basics of shell programming
 
PowerShell Remoting
PowerShell RemotingPowerShell Remoting
PowerShell Remoting
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
Getting started with Ansible
Getting started with AnsibleGetting started with Ansible
Getting started with Ansible
 
DevOps Meetup ansible
DevOps Meetup   ansibleDevOps Meetup   ansible
DevOps Meetup ansible
 

Viewers also liked

Introduction To Windows Power Shell
Introduction To Windows Power ShellIntroduction To Windows Power Shell
Introduction To Windows Power Shell
Microsoft TechNet
 
Active Directory et la Sécurité
Active Directory et la SécuritéActive Directory et la Sécurité
Active Directory et la Sécurité
Microsoft
 
Windows PowerShell
Windows PowerShellWindows PowerShell
Windows PowerShell
Sandun Perera
 
Active Directory en 2012 : les meilleures pratiques en design, sécurité et ad...
Active Directory en 2012 : les meilleures pratiques en design, sécurité et ad...Active Directory en 2012 : les meilleures pratiques en design, sécurité et ad...
Active Directory en 2012 : les meilleures pratiques en design, sécurité et ad...
Microsoft Technet France
 
Active directory
Active directory Active directory
Active directory deshvikas
 
Active Directory
Active Directory Active Directory
Active Directory
Sandeep Kapadane
 

Viewers also liked (6)

Introduction To Windows Power Shell
Introduction To Windows Power ShellIntroduction To Windows Power Shell
Introduction To Windows Power Shell
 
Active Directory et la Sécurité
Active Directory et la SécuritéActive Directory et la Sécurité
Active Directory et la Sécurité
 
Windows PowerShell
Windows PowerShellWindows PowerShell
Windows PowerShell
 
Active Directory en 2012 : les meilleures pratiques en design, sécurité et ad...
Active Directory en 2012 : les meilleures pratiques en design, sécurité et ad...Active Directory en 2012 : les meilleures pratiques en design, sécurité et ad...
Active Directory en 2012 : les meilleures pratiques en design, sécurité et ad...
 
Active directory
Active directory Active directory
Active directory
 
Active Directory
Active Directory Active Directory
Active Directory
 

Similar to Introduction to PowerShell

PowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersPowerShell for SharePoint Developers
PowerShell for SharePoint Developers
Boulos Dib
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and Puppet
Achieve Internet
 
Get-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for EvilGet-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for Evil
jaredhaight
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge Club
Essam Salah
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with Puppet
Alessandro Franceschi
 
NIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellNIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShell
Phan Hien
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellBrian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellSharePoint Saturday NY
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellBrian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellSharePoint Saturday NY
 
RichFaces - Testing on Mobile Devices
RichFaces - Testing on Mobile DevicesRichFaces - Testing on Mobile Devices
RichFaces - Testing on Mobile Devices
Pavol Pitoňák
 
Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010
Binh Nguyen
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
John Congdon
 
Ansible new paradigms for orchestration
Ansible new paradigms for orchestrationAnsible new paradigms for orchestration
Ansible new paradigms for orchestration
Paolo Tonin
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operationsgrim_radical
 
PowerShell 101
PowerShell 101PowerShell 101
PowerShell 101
Thomas Lee
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
Haehnchen
 
NZ Code Camp 2011 PowerShell + SharePoint
NZ Code Camp 2011 PowerShell + SharePointNZ Code Camp 2011 PowerShell + SharePoint
NZ Code Camp 2011 PowerShell + SharePoint
Nick Hadlee
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Fabrice Bernhard
 
Powershell Tech Ed2009
Powershell Tech Ed2009Powershell Tech Ed2009
Powershell Tech Ed2009rsnarayanan
 
A DevOps guide to Kubernetes
A DevOps guide to KubernetesA DevOps guide to Kubernetes
A DevOps guide to Kubernetes
Paul Czarkowski
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
Alan Pinstein
 

Similar to Introduction to PowerShell (20)

PowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersPowerShell for SharePoint Developers
PowerShell for SharePoint Developers
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and Puppet
 
Get-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for EvilGet-Help: An intro to PowerShell and how to Use it for Evil
Get-Help: An intro to PowerShell and how to Use it for Evil
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge Club
 
Developing IT infrastructures with Puppet
Developing IT infrastructures with PuppetDeveloping IT infrastructures with Puppet
Developing IT infrastructures with Puppet
 
NIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellNIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShell
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellBrian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
 
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with PowershellBrian Jackett: Managing SharePoint 2010 Farms with Powershell
Brian Jackett: Managing SharePoint 2010 Farms with Powershell
 
RichFaces - Testing on Mobile Devices
RichFaces - Testing on Mobile DevicesRichFaces - Testing on Mobile Devices
RichFaces - Testing on Mobile Devices
 
Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010Introduction to windows power shell in sharepoint 2010
Introduction to windows power shell in sharepoint 2010
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
Ansible new paradigms for orchestration
Ansible new paradigms for orchestrationAnsible new paradigms for orchestration
Ansible new paradigms for orchestration
 
PuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into OperationsPuppetDB: Sneaking Clojure into Operations
PuppetDB: Sneaking Clojure into Operations
 
PowerShell 101
PowerShell 101PowerShell 101
PowerShell 101
 
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years laterSymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
SymfonyCon Berlin 2016 - Symfony Plugin for PhpStorm - 3 years later
 
NZ Code Camp 2011 PowerShell + SharePoint
NZ Code Camp 2011 PowerShell + SharePointNZ Code Camp 2011 PowerShell + SharePoint
NZ Code Camp 2011 PowerShell + SharePoint
 
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
Adopt DevOps philosophy on your Symfony projects (Symfony Live 2011)
 
Powershell Tech Ed2009
Powershell Tech Ed2009Powershell Tech Ed2009
Powershell Tech Ed2009
 
A DevOps guide to Kubernetes
A DevOps guide to KubernetesA DevOps guide to Kubernetes
A DevOps guide to Kubernetes
 
Lean Php Presentation
Lean Php PresentationLean Php Presentation
Lean Php Presentation
 

Recently uploaded

IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
CatarinaPereira64715
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
Paul Groth
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
Product School
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 

Recently uploaded (20)

IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
ODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User GroupODC, Data Fabric and Architecture User Group
ODC, Data Fabric and Architecture User Group
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMsTo Graph or Not to Graph Knowledge Graph Architectures and LLMs
To Graph or Not to Graph Knowledge Graph Architectures and LLMs
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
From Daily Decisions to Bottom Line: Connecting Product Work to Revenue by VP...
 
Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 

Introduction to PowerShell

  • 2. Independent Consultant – Napeague Inc.  Software Development since 1983  Few Facts (@boulosdib)  First Personal Computer 1980 – TRS-80 III  First Z80 based product (EPROM based Protocol Adpator – 1984)  First Commercial PC-DOS product (Telex on PCs – 1985)  Started 16-bit Windows Development using Win 3.1  Developed on: 8080/Z80, 68xxx, PDP/RSX,VAX-VMS and x86/x64 (C/C++/C#)  Worked with PowerShell since Monad (2006)  Worked with SharePoint since STS (2003)  More facts ▪ Favorite sport – Windsurfing  ▪ Favorite hobby – Playing my sunburst Fender Stratocaster+ guitar. ▪ Favorite guitar players ▪ Wes Montgomery, Larry Carlton and Ritchie Blackmore (Deep Purple, Rainbow)
  • 3. Overview of PowerShell  Introduction to PowerShell Scripting Language  Tools  Script Authoring  SharePoint Management Console  SharePoint CmdLets
  • 4. NYC Code Camp  I will be presenting on LightSwitch and Silverlight at the NYC Code Camp 6 (Autumn 2011)  Saturday October 1st  Pace University  Registration Still Open  http://CodeCampNyc.org
  • 5. Interactive Command Shell  Programmatic (Script) Execution Environment  Dynamic Scripting Language  Extensible (CmdLets, .Net etc…)  Hosted (i.e. NuGet)  Management tool for Servers
  • 6. “A shell is the piece of software that lets you access the functionality provided by the operating system. “ Bruce Payette - Co-Designer and Implementer of the PowerShell language.  Example  Windows Explorer  Command.com  Cmd.exe  Bash (Unix)  PowerShell
  • 7. Interactive Environment with .Net  Automation Tool  Easy to use  Available on all Windows SKUs starting with XP SP2 and Windows 2003  Management tool for Servers  Productivity Gains – One Liner
  • 9. Common Parameters  -Verbose  -Debug  -WarningAction  -WarningVariable  -ErrorAction  -ErrorVariable  -OutVariable  -OutBuffer  Risk Mitigation Parameters (certainly critical in a production environment)  What-If  -Confirm  Wildcard support.  All names and parameter value can support wildcard.  Pipeline  Much more about this later.
  • 10. Command vs. Expression mode parsing  Echo 1+1  1+1  Everything returns a value  “String”  Variable  $ Prefix  i.e. $var = “Hello Sharepoint”  Type System  All .Net types as well as Custom Types
  • 11. Help  Get-Help (or -? Following any command)  Get-Help about_<<anyname>>  Get-Help –Examples  Get-Help –Full
  • 12. High level task oriented abstraction  Verb-XXNoun  Verbs: Get, Set, New, Write, Read  Nouns: Drive, Variable, Provider, Site, Collection  Get-Verb  Predefined Commands  When Starting Remember these:  Get-Help  Get-Member  Get-Command
  • 13. Get-Help  As it says, it helps!!!  Get-Command  Get information about what can be invoked  Get-Member  Show what can be done with an object  Get-Module  Show packages of commands  GetType  Discover details about an object’s type information.
  • 14. Compare  Foreach  Group  Measure  Select  Sort  Tee  Where
  • 15. PowerShell ISE  Simple Editor and Debugger  PowerGUI  Administrative Console  PowerGUI Editor  Powerpacks – a number to choose from.  Visual Studio  Notepad
  • 16. Out-Host  Out-Null  Out-Printer  Out-String  Out-GridView
  • 17. The best part about PowerShell  Output of one CmdLet is Input into next CmdLet in pipeline.  Uses the Pipe operator |  Output and Input are objects, not text like traditional shells.  Example ▪ Get-Command | Get-Member ▪ Get-Process | Out-GridView
  • 18. Case-Insensitive  Variables: begin with $ (i.e. $a = “test”)  Script Blocks using {}  Array $a = 1,2,3  $a[1]  Hashtable  $h = @{a=1; b=2}  Scope – Functions and Script Blocks  Security Context aware  Remoting - WSMan
  • 19. If then else  If ($a –eq “test”) { “It’s a test”} else {“Not”}  While loop and Do While loop  $i = 1; While ($i –lt 10) {$i++}  $i =5; do {$i} while (--$i)  For loop  for ($i=0; $i –lt 10; $i++) { “5 * $i is $(5 * $i)” }  Foreach loop  Foreach ($i in 1..10) {“`$i is $i”}
  • 20. Foreach CmdLet  1..10 | ForEach-Object {“begin”} {$_ * 2} {“end”}  Where Cmdlet  1..10 | Where-Object {$_ -gt 4 -and $_ -lt 10}
  • 21. Arithmetic Operators  +*-/%  Assignment Operators  =, +=, -=, *=, /=, %=
  • 22. Get-Location and SetLocation  Copy-Item  Remove-Item  Move-Item  Rename-Item  Set-Item  New-Item  Get-Content
  • 23. Pretty much the same as CMD  > replace file  >> Append to file  2> File is replaced with error messages  2>> Error text is appended to file  2>&1 Error messages are written to output pipe
  • 24. A module is a package that contains Windows PowerShell commands, such as cmdlets, providers, functions, variables, and aliases  Need to create module folder  new-item -type directory -path $homeDocumentsWindowsPowerShell Modules  Copy the module to the Modules folder.  Start using a module (import-module etc…)
  • 25. Standard Providers  Windows PowerShell providers are Microsoft .NET Framework-based programs that make the data in a specialized data store available in Windows PowerShell so that you can view and manage it  Get-PSProvider | Select -Property Name  WSMan -  Alias  Environment  FileSystem  Function  Registry  Variable  Certificate
  • 26. Get-PSDrive  New-PSDrive  New-PSDrive -Name Y -PSProvider FileSystem -Root c:temp  Remove-PSDrive  Remove-PSDrive  Try a non-disk PSDrive like cert: Dir Cert:
  • 27.  A Script file is a text file with .ps1 extension containing one or more PowerShell command  A Script is a simple mechanism to re-use functionality.  To run a script on a remote computer, use the Invoke-Command and provide remote computer name as a parameter.  Scripts can accept parameters.  To run a script in the current session, we Dot- Source the . .Script1.ps1  We can Scope Local or Global.
  • 28. Single Line: #  Multi Line:  <#  #>  Comments can be used to automatically generate help
  • 29. A function is a script block containing list of statements  function small_files ($size = 1kB) {  Get-ChildItem c:Temp | where { $_.length -lt $size -and !$_.PSIsContainer}  }  small_files  To control how a function uses the pipeline, you use Begin, Process and End.  function pipelineFunc {  process {"The value is: $_"} } 1,2,3 | pipelineFunc  Advanced functions allow you to write CmdLets using scripts instead of compiled code.
  • 30. try  {  $wc = new-object System.Net.WebClient  $wc.DownloadFile("http://www.contoso.com/MyDoc.doc","c:MyDoc.doc")  }  catch [System.Net.WebException],[System.IO.IOException]  {  "unable to download MyDoc.doc from http://www.contoso.com."  }  catch  {  "An error occurred that could not be resolved."  }
  • 31. Sharepoint Management Shell  Need to execute Add-SPShellAdmin in order to acquire permissions to run PowerShell on Sharepoint Member of Farm Member of Administrators Farm component Administrators SharePoint Full Control on backup folder group on the local computer group Farm Yes No Yes Service application Yes No Yes Content database Yes No Yes Site collection No Yes Yes Site, list, document library Yes No Yes Source: MSDN
  • 32. Get-Command -Noun SP*  (Get-Command –Name *-SP* - CommandType cmdLet).Count
  • 33. $Host.Runspace.ThreadOptions = "ReuseThread"  Get-SPAssignment –Global  $spWeb = Get-SPWeb -Identity $url  $spWeb.TreeViewEnabled = $True  $spWeb.Update()  Stop-SPAssignment –Global
  • 34. Windows Powershell Blog  http://blogs.msdn.com/b/powershell/  Doug Finke – MVP (Also ShowUI)  http://dougfinke.com/blog/  PowerShell Magazine  http://www.powershellmagazine.com/  Jim Christopher MVP (Check out StudioShell)  http://www.beefycode.com/  Tome Tanasovski MVP/Author – NYC PowerShell User Group  http://powertoe.wordpress.com/
  • 35. Productivity  PowerGUI http://PowerGUI.org  PowerTab http://powertab.codeplex.com/  Community Extensions http://pscx.codeplex.com  Quest ActiveRoles Management Shell http://www.quest.com/powershell/activeroles-server.aspx  UI  ShowUI (WPF) – http://showui.codeplex.com
  • 36. Tool Url PowerGUI http://PowerGUI.org/ PowerTab http://powertab.codeplex.com/ Community Extensions http://pscx.codeplex.com/ Quest ActiveRoles http://www.quest.com/powershell/activeroles- server.aspx/ ShowUI http://showui.codeplex.com/ Windows Automation Snaping for http://wasp.codeplex.com/ Powershell
  • 37. NuGet  http://nuget.org/  http://nuget.codeplex.com/  StudioShell  http://studioshell.codeplex.com/
  • 38. PowerShell in Action  Windows PowerShell 2.0 Bible  Bruce Payette  By Thomas Lee, Karl Mitschke, Mark  “The book from the authority on E. Schill, and Tome Tanasovski PowerShell”  http://powertoe.wordpress.com/
  • 39. Automating Microsoft SharePoint  PowerShell for Microsoft Sharepoint 2010 Administration with Windows 2010 Administrators. PowerShell 2.0  Gary Lapointe & Shannon Bray  Niklas Goude & Mattias Karlsson  http://blog.falchionconsulting.com/  http://www.powershell.nu/
  • 40. Next session will be about PowerShell Scripts in the SharePoint Management Shell  Contact:  http://blog.boulosdib.com  @boulosdib