SlideShare a Scribd company logo
1 of 26
Download to read offline
Boulos Dib
                            November 16, 2011
http://blog.boulosdib.com       @boulosdib
PS> Describe-Presenter
 Independent Consultant – Napeague Inc.
 Professional Software Development since 1983
 Few Facts
    First Personal Computer 1980 – TRS-80 III
    First Z80 based product (EPROM based Protocol Adaptor – 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)
Agenda
 Quick PowerShell Review
 SharePoint 2010 Management Shell
 PowerShell (Functions, CmdLet)
 SharePoint CmdLets by Group
 Best Practices
 Sample Scripts
 Tools
 Resources
PowerShell Review
 Interactive Command Shell
 Programmatic Execution Environment
 Dynamic Scripting Language
 Extensible (CmdLets, .Net etc…)
 Hosted (i.e. NuGet/PowerGUI vsix)
 Management tool for Servers
Review - What is a shell
“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
Review - Consistent Environment
 Common Parameters
    -Verbose
    -Debug
    -WarningAction
    -WarningVariable
    -ErrorAction
    -ErrorVariable
    -OutVariable
    -OutBuffer

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

 Whildcard support.
    All names and parameter value can support wildcard.
 Pipeline
Where do I start
 Verb-XXNoun
    Verbs: Get, Set, New, Write, Read
    Nouns: Drive, Variable, Provider, Site, Collection
 Most important command
    Get-Help
        Get-Help *
        Get-Help *drive*
    Get-Member
    Get-Command
PowerShell
 Functions
 Scripts
 Error Handling
 Parameters
 Splatting


 Remoting
 PSSession
Functions
 Functions is a script block containing list of statements
 function small_files ($size = 100MB) {
        Get-ChildItem c: | where { $_.length -lt $size -and
         !$_.PSIsContainer}
    }

 To control how a function uses the pipeline, you use Begin,
  Process and End.
 function pipelineFunction {
    process {"The value is: $_"}
   }
   1,2,3 | pipelineFunction

 Advanced functions allow you to write CmdLets using scripts
  instead of compiled code.
Scripts
 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.
Error Handling
 Terminating vs. Nonterminating Errors
 Trap
 Throw – Sometime useful for parameters
    function hi ($name=$(throw '$name is required')) {"Hi
     $name"}
Errors Handling – as in C#
   try
   {
         $wc = new-object System.Net.WebClient
         $wc.DownloadFile("http://www.contoso.com/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."
   }
Snapins, Providers and Drives
 Get-PSProvider | Format-List Name, PSSnapin
 Get-PSSnapin
 Get-PSProvider
 Get-PSDrive
PowerShell Modules
 Get-Module –ListAvailable




 Import-Module ActiveDirectory
SharePoint Management Shell
 SharePoint Management Shell differs slightly from
  the Standard PowerShell:

 Runspace Threading
   $Host.Runspace.ThreadOptions = "ReuseThread“



 SharePoint Specific Snap-In
   Add-PSSnapin Microsoft.SharePoint.PowerShell
Threading & Proper Object
Disposal
 $Host.Runspace.ThreadOptions = "ReuseThread"


 Get-SPAssignment –Global
    $spWeb = Get-SPWeb -Identity $url
    $spWeb.TreeViewEnabled = $True
    $spWeb.Update()
 Stop-SPAssignment –Global
Sharepoint CmdLets Groups
 Farm
 Application
 Solution
 Site Collection
 Site
 List and ListItem
Farm
 Backup-SPFarm
 Get-SPFarm
 Restore-SPFarm
Web Application
 Get-SPWebApplication
 New-SPWebApplication
 Remove-SPWebApplication
 Set-SPWebApplication
Solutions
 Get-SPSolution
 Add-SPSolution
 Remove-SPSolution
 Install-SPSolution
 UnInstall-SPSolution
 Update-SPSolution
Site Collections
 Backup-SPSite
 Get-SPSite
 Move-SPSite
 New-SPSite
 Remove-SPSite
 Restore-SPSite
 Set-SPSite
Sites
 Export-SPWeb
 Get-SPWeb
 Import-SPWeb
 New-SPWeb
 Remove-SPWeb
 Set-SPWeb
Tools - Productivity
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 Snapin   http://wasp.codeplex.com/
for PowerShell
Visual Studio Hosted
 NuGet
   http://nuget.org/
   http://nuget.codeplex.com/


 PowerGUI vsix
    http://powerguivsx.codeplex.com/


 StudioShell
    http://studioshell.codeplex.com/
Books – PowerShell
 PowerShell in Action                 Windows PowerShell 2.0 Bible
 Bruce Payette                        By Thomas Lee, Karl Mitschke,
 “The book from the authority on       Mark E. Schill, and Tome
  PowerShell”                           Tanasovski
                                        http://powertoe.wordpress.com/
                                        (Tome’s blog)
Books – PowerShell & SharePoint
 Automating Microsoft SharePoint          PowerShell for Microsoft
  2010 Administration with Windows          Sharepoint 2010 Administrators.
  PowerShell 2.0
 Gary Lapointe & Shannon Bray           Niklas Goude & Mattias Karlsson
 http://blog.falchionconsulting.com/    http://www.powershell.nu/
                                         http://mysharepointofview.com/
 http://sppowershell.com/

More Related Content

What's hot

ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0Ido Flatow
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseTaylor Lovett
 
Isomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWPIsomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWPTaylor Lovett
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescueMarko Heijnen
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIsmdawaffe
 
Here Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressHere Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressRami Sayar
 
Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The BasicsPhilip Langer
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance DrupalJeff Geerling
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPressTaylor Lovett
 
Play! Framework for JavaEE Developers
Play! Framework for JavaEE DevelopersPlay! Framework for JavaEE Developers
Play! Framework for JavaEE DevelopersTeng Shiu Huang
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentationToufiq Mahmud
 
Django rest framework
Django rest frameworkDjango rest framework
Django rest frameworkBlank Chen
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataStacy London
 
Chef and PowerShell Desired State Configuration
Chef and PowerShell Desired State ConfigurationChef and PowerShell Desired State Configuration
Chef and PowerShell Desired State ConfigurationJulian Dunn
 
Integration and Acceptance Testing
Integration and Acceptance TestingIntegration and Acceptance Testing
Integration and Acceptance TestingAlan Hecht
 
Embracing HTTP in the era of API’s
Embracing HTTP in the era of API’sEmbracing HTTP in the era of API’s
Embracing HTTP in the era of API’sVisug
 
Intro to Coldfusion
Intro to ColdfusionIntro to Coldfusion
Intro to ColdfusionTerry Ryan
 

What's hot (20)

ASP.NET Core 1.0
ASP.NET Core 1.0ASP.NET Core 1.0
ASP.NET Core 1.0
 
Best Practices for WordPress in Enterprise
Best Practices for WordPress in EnterpriseBest Practices for WordPress in Enterprise
Best Practices for WordPress in Enterprise
 
Isomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWPIsomorphic WordPress Applications with NodeifyWP
Isomorphic WordPress Applications with NodeifyWP
 
Node.js to the rescue
Node.js to the rescueNode.js to the rescue
Node.js to the rescue
 
Fluxible
FluxibleFluxible
Fluxible
 
WordPress APIs
WordPress APIsWordPress APIs
WordPress APIs
 
Here Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPressHere Be Dragons - Debugging WordPress
Here Be Dragons - Debugging WordPress
 
Play Framework: The Basics
Play Framework: The BasicsPlay Framework: The Basics
Play Framework: The Basics
 
High Performance Drupal
High Performance DrupalHigh Performance Drupal
High Performance Drupal
 
JSON REST API for WordPress
JSON REST API for WordPressJSON REST API for WordPress
JSON REST API for WordPress
 
Extending ansible
Extending ansibleExtending ansible
Extending ansible
 
Play! Framework for JavaEE Developers
Play! Framework for JavaEE DevelopersPlay! Framework for JavaEE Developers
Play! Framework for JavaEE Developers
 
Laravel presentation
Laravel presentationLaravel presentation
Laravel presentation
 
Django rest framework
Django rest frameworkDjango rest framework
Django rest framework
 
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember DataIn The Trenches With Tomster, Upgrading Ember.js & Ember Data
In The Trenches With Tomster, Upgrading Ember.js & Ember Data
 
Chef and PowerShell Desired State Configuration
Chef and PowerShell Desired State ConfigurationChef and PowerShell Desired State Configuration
Chef and PowerShell Desired State Configuration
 
Intro to Laravel
Intro to LaravelIntro to Laravel
Intro to Laravel
 
Integration and Acceptance Testing
Integration and Acceptance TestingIntegration and Acceptance Testing
Integration and Acceptance Testing
 
Embracing HTTP in the era of API’s
Embracing HTTP in the era of API’sEmbracing HTTP in the era of API’s
Embracing HTTP in the era of API’s
 
Intro to Coldfusion
Intro to ColdfusionIntro to Coldfusion
Intro to Coldfusion
 

Viewers also liked

What i have learnt about technologies from the
What i have learnt about technologies from theWhat i have learnt about technologies from the
What i have learnt about technologies from theentwistlesophie8064
 
Assignment 11 (draft 2)
Assignment 11 (draft 2)Assignment 11 (draft 2)
Assignment 11 (draft 2)debbie14
 
Dtq4_ita
Dtq4_itaDtq4_ita
Dtq4_itaDTQ4
 
Taddei classroom management
Taddei classroom managementTaddei classroom management
Taddei classroom managementetaddeiwilkes
 
Handelsbeleid in steden en gemeenten (UNIZO Burgemeestersonbijt 16/01/14)
Handelsbeleid in steden en gemeenten (UNIZO Burgemeestersonbijt 16/01/14)Handelsbeleid in steden en gemeenten (UNIZO Burgemeestersonbijt 16/01/14)
Handelsbeleid in steden en gemeenten (UNIZO Burgemeestersonbijt 16/01/14)Bert Serneels
 
Presentatie oefenzitting5
Presentatie oefenzitting5Presentatie oefenzitting5
Presentatie oefenzitting5ThomasPlancke
 
Front cover & contents page research
Front cover & contents page researchFront cover & contents page research
Front cover & contents page research05colesben
 
PMSight References
PMSight ReferencesPMSight References
PMSight ReferencesPaul Viviers
 
Corporate_Training at CETPA Campus for IBM AIX 6.1
Corporate_Training at CETPA Campus for IBM AIX 6.1Corporate_Training at CETPA Campus for IBM AIX 6.1
Corporate_Training at CETPA Campus for IBM AIX 6.1Vikash Kumar
 
The real makalah ( reaksi kimia dalam larutan air )
The real makalah ( reaksi kimia dalam larutan air )The real makalah ( reaksi kimia dalam larutan air )
The real makalah ( reaksi kimia dalam larutan air )Sylvester Saragih
 
36kr no.94
36kr no.9436kr no.94
36kr no.94Gina Gu
 
Planning for draft 3
Planning for draft 3Planning for draft 3
Planning for draft 3debbie14
 
Primero bmo presentation final
Primero bmo presentation finalPrimero bmo presentation final
Primero bmo presentation finalprimero_mining
 

Viewers also liked (20)

What i have learnt about technologies from the
What i have learnt about technologies from theWhat i have learnt about technologies from the
What i have learnt about technologies from the
 
Assignment 11 (draft 2)
Assignment 11 (draft 2)Assignment 11 (draft 2)
Assignment 11 (draft 2)
 
Dtq4_ita
Dtq4_itaDtq4_ita
Dtq4_ita
 
Tugas kimia dasar 1 part 2
Tugas kimia dasar 1 part 2Tugas kimia dasar 1 part 2
Tugas kimia dasar 1 part 2
 
Taddei classroom management
Taddei classroom managementTaddei classroom management
Taddei classroom management
 
Handelsbeleid in steden en gemeenten (UNIZO Burgemeestersonbijt 16/01/14)
Handelsbeleid in steden en gemeenten (UNIZO Burgemeestersonbijt 16/01/14)Handelsbeleid in steden en gemeenten (UNIZO Burgemeestersonbijt 16/01/14)
Handelsbeleid in steden en gemeenten (UNIZO Burgemeestersonbijt 16/01/14)
 
00135
0013500135
00135
 
Presentatie oefenzitting5
Presentatie oefenzitting5Presentatie oefenzitting5
Presentatie oefenzitting5
 
Game animals
Game animalsGame animals
Game animals
 
Front cover & contents page research
Front cover & contents page researchFront cover & contents page research
Front cover & contents page research
 
PMSight References
PMSight ReferencesPMSight References
PMSight References
 
Asteroïde
AsteroïdeAsteroïde
Asteroïde
 
We didn't watch tv
We didn't watch tvWe didn't watch tv
We didn't watch tv
 
Internet
InternetInternet
Internet
 
Corporate_Training at CETPA Campus for IBM AIX 6.1
Corporate_Training at CETPA Campus for IBM AIX 6.1Corporate_Training at CETPA Campus for IBM AIX 6.1
Corporate_Training at CETPA Campus for IBM AIX 6.1
 
The real makalah ( reaksi kimia dalam larutan air )
The real makalah ( reaksi kimia dalam larutan air )The real makalah ( reaksi kimia dalam larutan air )
The real makalah ( reaksi kimia dalam larutan air )
 
36kr no.94
36kr no.9436kr no.94
36kr no.94
 
Planning for draft 3
Planning for draft 3Planning for draft 3
Planning for draft 3
 
Question 4
Question 4Question 4
Question 4
 
Primero bmo presentation final
Primero bmo presentation finalPrimero bmo presentation final
Primero bmo presentation final
 

Similar to Boulos Dib's Guide to PowerShell and SharePoint Management

Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellBoulos Dib
 
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
 
Automating PowerShell with SharePoint
Automating PowerShell with SharePointAutomating PowerShell with SharePoint
Automating PowerShell with SharePointTalbott Crowell
 
Power shell training
Power shell trainingPower shell training
Power shell trainingDavid Brabant
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubEssam Salah
 
Wsv406 Advanced Automation Using Windows Power Shell2.0
Wsv406 Advanced Automation Using Windows Power Shell2.0Wsv406 Advanced Automation Using Windows Power Shell2.0
Wsv406 Advanced Automation Using Windows Power Shell2.0jsnover1
 
Post exploitation using powershell
Post exploitation using powershellPost exploitation using powershell
Post exploitation using powershellMihir Shah
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetAchieve Internet
 
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdfLearn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdfClapperboardCinemaPV
 
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 Eviljaredhaight
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidenceJohn Congdon
 
PowerShell Technical Overview
PowerShell Technical OverviewPowerShell Technical Overview
PowerShell Technical Overviewallandcp
 
Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009John Clayton
 
NZ Code Camp 2011 PowerShell + SharePoint
NZ Code Camp 2011 PowerShell + SharePointNZ Code Camp 2011 PowerShell + SharePoint
NZ Code Camp 2011 PowerShell + SharePointNick Hadlee
 
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 2010Binh Nguyen
 

Similar to Boulos Dib's Guide to PowerShell and SharePoint Management (20)

Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to 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
 
Automating PowerShell with SharePoint
Automating PowerShell with SharePointAutomating PowerShell with SharePoint
Automating PowerShell with SharePoint
 
Power shell training
Power shell trainingPower shell training
Power shell training
 
Windows PowerShell
Windows PowerShellWindows PowerShell
Windows PowerShell
 
Powershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge ClubPowershell Seminar @ ITWorx CuttingEdge Club
Powershell Seminar @ ITWorx CuttingEdge Club
 
Wsv406 Advanced Automation Using Windows Power Shell2.0
Wsv406 Advanced Automation Using Windows Power Shell2.0Wsv406 Advanced Automation Using Windows Power Shell2.0
Wsv406 Advanced Automation Using Windows Power Shell2.0
 
Post exploitation using powershell
Post exploitation using powershellPost exploitation using powershell
Post exploitation using powershell
 
Harmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and PuppetHarmonious Development: Via Vagrant and Puppet
Harmonious Development: Via Vagrant and Puppet
 
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdfLearn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
Learn Powershell Scripting Tutorial Full Course 1dollarcart.com.pdf
 
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
 
Release with confidence
Release with confidenceRelease with confidence
Release with confidence
 
PowerShell-1
PowerShell-1PowerShell-1
PowerShell-1
 
PowerShell Technical Overview
PowerShell Technical OverviewPowerShell Technical Overview
PowerShell Technical Overview
 
Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009Windows PowerShell - Billings .NET User Group - August 2009
Windows PowerShell - Billings .NET User Group - August 2009
 
NZ Code Camp 2011 PowerShell + SharePoint
NZ Code Camp 2011 PowerShell + SharePointNZ Code Camp 2011 PowerShell + SharePoint
NZ Code Camp 2011 PowerShell + SharePoint
 
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
 
One-Man Ops
One-Man OpsOne-Man Ops
One-Man Ops
 
PowerShell Remoting
PowerShell RemotingPowerShell Remoting
PowerShell Remoting
 

Recently uploaded

Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Developmentchesterberbo7
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...DhatriParmar
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQuiz Club NITW
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmStan Meyer
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWQuiz Club NITW
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Celine George
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...DhatriParmar
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operationalssuser3e220a
 
CHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptxCHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptxAneriPatwari
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptxmary850239
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxSayali Powar
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptxmary850239
 

Recently uploaded (20)

Using Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea DevelopmentUsing Grammatical Signals Suitable to Patterns of Idea Development
Using Grammatical Signals Suitable to Patterns of Idea Development
 
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
Blowin' in the Wind of Caste_ Bob Dylan's Song as a Catalyst for Social Justi...
 
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITWQ-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
Q-Factor HISPOL Quiz-6th April 2024, Quiz Club NITW
 
Oppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and FilmOppenheimer Film Discussion for Philosophy and Film
Oppenheimer Film Discussion for Philosophy and Film
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Mythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITWMythology Quiz-4th April 2024, Quiz Club NITW
Mythology Quiz-4th April 2024, Quiz Club NITW
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17Tree View Decoration Attribute in the Odoo 17
Tree View Decoration Attribute in the Odoo 17
 
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
Beauty Amidst the Bytes_ Unearthing Unexpected Advantages of the Digital Wast...
 
Expanded definition: technical and operational
Expanded definition: technical and operationalExpanded definition: technical and operational
Expanded definition: technical and operational
 
CHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptxCHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptx
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptxBIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
BIOCHEMISTRY-CARBOHYDRATE METABOLISM CHAPTER 2.pptx
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx4.16.24 21st Century Movements for Black Lives.pptx
4.16.24 21st Century Movements for Black Lives.pptx
 

Boulos Dib's Guide to PowerShell and SharePoint Management

  • 1. Boulos Dib November 16, 2011 http://blog.boulosdib.com @boulosdib
  • 2. PS> Describe-Presenter  Independent Consultant – Napeague Inc.  Professional Software Development since 1983  Few Facts  First Personal Computer 1980 – TRS-80 III  First Z80 based product (EPROM based Protocol Adaptor – 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. Agenda  Quick PowerShell Review  SharePoint 2010 Management Shell  PowerShell (Functions, CmdLet)  SharePoint CmdLets by Group  Best Practices  Sample Scripts  Tools  Resources
  • 4. PowerShell Review  Interactive Command Shell  Programmatic Execution Environment  Dynamic Scripting Language  Extensible (CmdLets, .Net etc…)  Hosted (i.e. NuGet/PowerGUI vsix)  Management tool for Servers
  • 5. Review - What is a shell “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
  • 6. Review - Consistent Environment  Common Parameters  -Verbose  -Debug  -WarningAction  -WarningVariable  -ErrorAction  -ErrorVariable  -OutVariable  -OutBuffer  Risk Mitigation Parameters (certainly critical in a production environment)  What-If  -Confirm  Whildcard support.  All names and parameter value can support wildcard.  Pipeline
  • 7. Where do I start  Verb-XXNoun  Verbs: Get, Set, New, Write, Read  Nouns: Drive, Variable, Provider, Site, Collection  Most important command  Get-Help  Get-Help *  Get-Help *drive*  Get-Member  Get-Command
  • 8. PowerShell  Functions  Scripts  Error Handling  Parameters  Splatting  Remoting  PSSession
  • 9. Functions  Functions is a script block containing list of statements  function small_files ($size = 100MB) {  Get-ChildItem c: | where { $_.length -lt $size -and !$_.PSIsContainer}  }  To control how a function uses the pipeline, you use Begin, Process and End.  function pipelineFunction {  process {"The value is: $_"} } 1,2,3 | pipelineFunction  Advanced functions allow you to write CmdLets using scripts instead of compiled code.
  • 10. Scripts  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.
  • 11. Error Handling  Terminating vs. Nonterminating Errors  Trap  Throw – Sometime useful for parameters  function hi ($name=$(throw '$name is required')) {"Hi $name"}
  • 12. Errors Handling – as in C#  try  {  $wc = new-object System.Net.WebClient  $wc.DownloadFile("http://www.contoso.com/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."  }
  • 13. Snapins, Providers and Drives  Get-PSProvider | Format-List Name, PSSnapin  Get-PSSnapin  Get-PSProvider  Get-PSDrive
  • 14. PowerShell Modules  Get-Module –ListAvailable  Import-Module ActiveDirectory
  • 15. SharePoint Management Shell  SharePoint Management Shell differs slightly from the Standard PowerShell:  Runspace Threading  $Host.Runspace.ThreadOptions = "ReuseThread“  SharePoint Specific Snap-In  Add-PSSnapin Microsoft.SharePoint.PowerShell
  • 16. Threading & Proper Object Disposal  $Host.Runspace.ThreadOptions = "ReuseThread"  Get-SPAssignment –Global  $spWeb = Get-SPWeb -Identity $url  $spWeb.TreeViewEnabled = $True  $spWeb.Update()  Stop-SPAssignment –Global
  • 17. Sharepoint CmdLets Groups  Farm  Application  Solution  Site Collection  Site  List and ListItem
  • 19. Web Application  Get-SPWebApplication  New-SPWebApplication  Remove-SPWebApplication  Set-SPWebApplication
  • 20. Solutions  Get-SPSolution  Add-SPSolution  Remove-SPSolution  Install-SPSolution  UnInstall-SPSolution  Update-SPSolution
  • 21. Site Collections  Backup-SPSite  Get-SPSite  Move-SPSite  New-SPSite  Remove-SPSite  Restore-SPSite  Set-SPSite
  • 22. Sites  Export-SPWeb  Get-SPWeb  Import-SPWeb  New-SPWeb  Remove-SPWeb  Set-SPWeb
  • 23. Tools - Productivity 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 Snapin http://wasp.codeplex.com/ for PowerShell
  • 24. Visual Studio Hosted  NuGet  http://nuget.org/  http://nuget.codeplex.com/  PowerGUI vsix  http://powerguivsx.codeplex.com/  StudioShell  http://studioshell.codeplex.com/
  • 25. Books – PowerShell  PowerShell in Action  Windows PowerShell 2.0 Bible  Bruce Payette  By Thomas Lee, Karl Mitschke,  “The book from the authority on Mark E. Schill, and Tome PowerShell” Tanasovski  http://powertoe.wordpress.com/ (Tome’s blog)
  • 26. Books – PowerShell & SharePoint  Automating Microsoft SharePoint  PowerShell for Microsoft 2010 Administration with Windows Sharepoint 2010 Administrators. PowerShell 2.0  Gary Lapointe & Shannon Bray  Niklas Goude & Mattias Karlsson  http://blog.falchionconsulting.com/  http://www.powershell.nu/  http://mysharepointofview.com/  http://sppowershell.com/