SlideShare a Scribd company logo
1 of 31
Introduction to Windows PowerShell in SharePoint 2010 Gia Duy Mai Solutions Assistant Lead Bamboo Solutions
Agenda Introduction to PowerShell Why PowerShell for SharePoint? When use PowerShell? PowerShellvs STSADM Getting started with PowerShell Controlling PowerShell with variables, loops, logic, and functions Creating your own PowerShell scripts  Scheduling your PowerShell scripts Demo Q&A
Introduction to PowerShell ,[object Object],Working with a command-line interface, often called a shell ,[object Object]
A modern replacement for the CMD (command) shell
PowerShell works with objects
PowerShell integrates with the .Net Framework
PowerShell is based on a provider-based model
A powerful scripting environment for administration,[object Object]
The Pipeline What is Pipeline? ,[object Object]
Pipelining allow one Cmdlet to return an object as input to anotherC#:  X = Class.Method(); Y = OtherClass.Method(X); Z = OtherOtherClass.Method(Y) PowerShell: Class.Method() | OtherClass.Method() | OtherOtherClass.Method()
Why PowerShell for SharePoint 2010?  Automated build and deploy Rapid prototyping Remoting interface Administration automation Easy for controlling, manipulating and modifying our SharePoint environment ,[object Object],STSADM.EXE We’ll miss you old friend
PowerShell vs STSADM
PowerShell vs STSADM - Performance Performance benefits for batch operations STSADM Batch Operation PowerShell Cmdlets in Batch Start Thread New STSADM Execution Start Thread Load DLLs Start logging Repeat Start Logging Execute Command Repeat Execute Command Stop logging Stop Logging Stop Thread Close STSADM & Thread
PowerShell vs STSADM - Performance PowerShell “Wrapped” STSADM to enable a feature on every SPSite Same command in SharePoint 2010 PowerShell: $rawdata = stsadm.exe -o enumsites -url $WebAppURL  $sitexml = [XML]$rawdata $sitesxml.Sites | foreach-object{ $_.Site } | foreach-object{  	stsadm -o activatefeature -url$_.url -filename $featureFileName          if( $lastexitcode -ne 0 ){              Write-Host “Failure:$lastexitcode  " -Fore Red;             $failure = $true;           } } 12+ Hours (5300 SPSites) 30 Minutes (5300 SPSites) Get-SPSite –Limit ALL –WebApplication $WebAppNameorUrl |%{  Enable-SPFeature$FeatureIdOrName –url $_.Url  }
When use PowerShell? When you want to make your team more agile 	- Automation, automation, automation ,[object Object],    - Using PowerShell to save time for Build/Deploy/Test Cycle Testing phase Using the PowerShell scripts to stand up an environment for running tests Traditional SharePoint Development Wasted time for testing When you use PowerShell
Who should learn PowerShell? ,[object Object],Why you should learn PowerShell? Microsoft says it’s important You can’t do everything from the GUI any more It can make your life easier Most Microsoft products will eventually use it Microsoft certification exams contain PowerShell questions Improve your job It’s not going away anytime soon
Getting Started with PowerShell (1) Execute a Cmdlet (2) Filter results using where clause (3) Add formatting instructions (4) Redirect output to new text file
Getting Help in PowerShell
Controlling PowerShell with variables, loops, logic, and functions
Variables in PowerShell A variable is a place for you to store some value so you can revisit it later. All variables that you create begin with $ 	Ex: $my_first_variable=  “Hello  World” Variables Types 	Loosely typed variables $f = “bar”        #implicitly typed as string $ary= 4,2,5,2     #typed as object[] 	Strongly typed variables [string]$f = “bar” 	Enhanced Types variables [xml]$d = “<a><b><c>c stuff 1</c><c>c stuff 2</c></b></a>”
Looping in PowerShell  Classic PowerShell Loop - For Loop $i = 10  For($j = 1; $j-lt $i; $j++){    Write-Host ”$j”; } - ForeachLoop 		$NumArray= (1,2,3,4,5,6,7,8,9,10)Foreach($Item in $NumArray) {$Item * 3} 	- While Loop $i =8 While ($i-le 96) { $i+=8; Write-Host$i; } 	- Do Until Loop $i = 7;  do { $i+=7; Write-Host$i; } until ($i-gt 85) ForeachLoop with Pipeline Get-SPSite -Limit All |  foreach {  Remove-SPSite -identity $_.Id   } $_ and is a variable that represents the current object
Adding logic in PowerShell  Logic is what enables you to do something at a specific point in the program. Statements If/ ElseIf/ Else Switch While  Comparison Operators -eq/-ne -lt / -gt -le / -ge -like / -notlike -contains/-notcontains -replace …
Working with PowerShell functions FunctionListRootDrive($DriveLetter) 	{  Get-ChildItem–Path  $DriveLetter} Function  ListRootDrive 	{  Get-ChildItem–Path  $Args} FunctionListRootDrive 	{  Get-ChildItem–Path  $Args[0]  } FunctionBlogUsers($SiteCollection)  { Get-SPWeb-Site  $SiteCollection|  ForEach-Object  { Write-Host  “Site  Title: “  $_.Title if  (  $_.Title  -eq “Blog”  )  { Write-Host  “Blog  Users:”  $_.Users }}}
PowerShell Aliases PowerShell commands are usually long. However, PowerShell has aliases. You can use aliases to save yourself the time and effort of typing cmdlets ,[object Object]
Foreach-Object ~ %
Get-ChildItem|foreach-object { $_.Name  }
Alias: dir|% { $_.Name }
Where-Object ~ ?
Get-ChildItem|where-object{$_.Length –gt10}
Alias: dir|?{$_.Length –gt10}You can find these aliases with the Get-Aliascmdlet
Creating your own PowerShell scripts

More Related Content

What's hot

OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010ikailan
 
Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Jesus Manuel Olivas
 
8 Minutes On Rack
8 Minutes On Rack8 Minutes On Rack
8 Minutes On Rackdanwrong
 
Webinar - Office 365 & PowerShell : A Match Made in Heaven
Webinar - Office 365 & PowerShell : A Match Made in HeavenWebinar - Office 365 & PowerShell : A Match Made in Heaven
Webinar - Office 365 & PowerShell : A Match Made in HeavenSébastien Levert
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsSadayuki Furuhashi
 
Ansible : what's ansible & use case by REX
Ansible :  what's ansible & use case by REXAnsible :  what's ansible & use case by REX
Ansible : what's ansible & use case by REXSaewoong Lee
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecturepostrational
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python MeetupAreski Belaid
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Lar21
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play FrameworkKnoldus Inc.
 
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEWINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEHitesh Mohapatra
 
PowerShell Fundamentals
PowerShell FundamentalsPowerShell Fundamentals
PowerShell Fundamentalsmozdzen
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode ChefSri Ram
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Elena Kolevska
 
Extending Oracle E-Business Suite with Ruby on Rails
Extending Oracle E-Business Suite with Ruby on RailsExtending Oracle E-Business Suite with Ruby on Rails
Extending Oracle E-Business Suite with Ruby on RailsRaimonds Simanovskis
 
Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.SWAAM Tech
 

What's hot (20)

OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010OSCON Google App Engine Codelab - July 2010
OSCON Google App Engine Codelab - July 2010
 
Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...Creating a modern web application using Symfony API Platform, ReactJS and Red...
Creating a modern web application using Symfony API Platform, ReactJS and Red...
 
8 Minutes On Rack
8 Minutes On Rack8 Minutes On Rack
8 Minutes On Rack
 
Webinar - Office 365 & PowerShell : A Match Made in Heaven
Webinar - Office 365 & PowerShell : A Match Made in HeavenWebinar - Office 365 & PowerShell : A Match Made in Heaven
Webinar - Office 365 & PowerShell : A Match Made in Heaven
 
Plugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGemsPlugin-based software design with Ruby and RubyGems
Plugin-based software design with Ruby and RubyGems
 
Ansible : what's ansible & use case by REX
Ansible :  what's ansible & use case by REXAnsible :  what's ansible & use case by REX
Ansible : what's ansible & use case by REX
 
Scalable web application architecture
Scalable web application architectureScalable web application architecture
Scalable web application architecture
 
Flask Introduction - Python Meetup
Flask Introduction - Python MeetupFlask Introduction - Python Meetup
Flask Introduction - Python Meetup
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Rails 4.0
Rails 4.0Rails 4.0
Rails 4.0
 
Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18Flask - Backend com Python - Semcomp 18
Flask - Backend com Python - Semcomp 18
 
Intoduction to Play Framework
Intoduction to Play FrameworkIntoduction to Play Framework
Intoduction to Play Framework
 
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISEWINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
WINDOWS ADMINISTRATION AND WORKING WITH OBJECTS : PowerShell ISE
 
PowerShell Fundamentals
PowerShell FundamentalsPowerShell Fundamentals
PowerShell Fundamentals
 
Cloud Automation with Opscode Chef
Cloud Automation with Opscode ChefCloud Automation with Opscode Chef
Cloud Automation with Opscode Chef
 
Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5Bootstrat REST APIs with Laravel 5
Bootstrat REST APIs with Laravel 5
 
Extending Oracle E-Business Suite with Ruby on Rails
Extending Oracle E-Business Suite with Ruby on RailsExtending Oracle E-Business Suite with Ruby on Rails
Extending Oracle E-Business Suite with Ruby on Rails
 
CakePHP
CakePHPCakePHP
CakePHP
 
Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.Laravel - Website Development in Php Framework.
Laravel - Website Development in Php Framework.
 
Kyiv.py #17 Flask talk
Kyiv.py #17 Flask talkKyiv.py #17 Flask talk
Kyiv.py #17 Flask talk
 

Similar to Introduction to windows power shell in sharepoint 2010

Getting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingGetting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingRavikanth Chaganti
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellBoulos Dib
 
Automating PowerShell with SharePoint
Automating PowerShell with SharePointAutomating PowerShell with SharePoint
Automating PowerShell with SharePointTalbott Crowell
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckrICh morrow
 
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
 
Intro to PowerShell
Intro to PowerShellIntro to PowerShell
Intro to PowerShellAdam Preston
 
PowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersPowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersBoulos Dib
 
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
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShellSalaudeen Rajack
 
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
 
NIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellNIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellPhan Hien
 
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshopIntroduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshopMichael Blumenthal (Microsoft MVP)
 
Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018Adam Tomat
 
PowerShell Zero To Hero Workshop!
PowerShell Zero To Hero Workshop!PowerShell Zero To Hero Workshop!
PowerShell Zero To Hero Workshop!Daisy Stevens
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practicesmanugoel2003
 
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...Michael Blumenthal (Microsoft MVP)
 
Power shell for sp admins
Power shell for sp adminsPower shell for sp admins
Power shell for sp adminsRick Taylor
 
Introduction to powershell
Introduction to powershellIntroduction to powershell
Introduction to powershellSalaudeen Rajack
 

Similar to Introduction to windows power shell in sharepoint 2010 (20)

Getting Started With PowerShell Scripting
Getting Started With PowerShell ScriptingGetting Started With PowerShell Scripting
Getting Started With PowerShell Scripting
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
Automating PowerShell with SharePoint
Automating PowerShell with SharePointAutomating PowerShell with SharePoint
Automating PowerShell with SharePoint
 
PHP from soup to nuts Course Deck
PHP from soup to nuts Course DeckPHP from soup to nuts Course Deck
PHP from soup to nuts Course Deck
 
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
 
Intro to PowerShell
Intro to PowerShellIntro to PowerShell
Intro to PowerShell
 
PowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersPowerShell for SharePoint Developers
PowerShell for SharePoint Developers
 
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
 
Introduction to PowerShell
Introduction to PowerShellIntroduction to PowerShell
Introduction to PowerShell
 
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
 
NIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShellNIIT ISAS Q5 Report - Windows PowerShell
NIIT ISAS Q5 Report - Windows PowerShell
 
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshopIntroduction to PowerShell - Be a PowerShell Hero - SPFest workshop
Introduction to PowerShell - Be a PowerShell Hero - SPFest workshop
 
Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018Supercharging WordPress Development in 2018
Supercharging WordPress Development in 2018
 
PowerShell Zero To Hero Workshop!
PowerShell Zero To Hero Workshop!PowerShell Zero To Hero Workshop!
PowerShell Zero To Hero Workshop!
 
Drupal Best Practices
Drupal Best PracticesDrupal Best Practices
Drupal Best Practices
 
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
Introduction to PowerShell for SharePoint Admins and Developers - SharePoint ...
 
Power shell for sp admins
Power shell for sp adminsPower shell for sp admins
Power shell for sp admins
 
Introduction to powershell
Introduction to powershellIntroduction to powershell
Introduction to powershell
 
Modern php
Modern phpModern php
Modern php
 

Recently uploaded

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDGMarianaLemus7
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 

Recently uploaded (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
APIForce Zurich 5 April Automation LPDG
APIForce Zurich 5 April  Automation LPDGAPIForce Zurich 5 April  Automation LPDG
APIForce Zurich 5 April Automation LPDG
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 

Introduction to windows power shell in sharepoint 2010

  • 1. Introduction to Windows PowerShell in SharePoint 2010 Gia Duy Mai Solutions Assistant Lead Bamboo Solutions
  • 2. Agenda Introduction to PowerShell Why PowerShell for SharePoint? When use PowerShell? PowerShellvs STSADM Getting started with PowerShell Controlling PowerShell with variables, loops, logic, and functions Creating your own PowerShell scripts Scheduling your PowerShell scripts Demo Q&A
  • 3.
  • 4. A modern replacement for the CMD (command) shell
  • 6. PowerShell integrates with the .Net Framework
  • 7. PowerShell is based on a provider-based model
  • 8.
  • 9.
  • 10. Pipelining allow one Cmdlet to return an object as input to anotherC#: X = Class.Method(); Y = OtherClass.Method(X); Z = OtherOtherClass.Method(Y) PowerShell: Class.Method() | OtherClass.Method() | OtherOtherClass.Method()
  • 11.
  • 13. PowerShell vs STSADM - Performance Performance benefits for batch operations STSADM Batch Operation PowerShell Cmdlets in Batch Start Thread New STSADM Execution Start Thread Load DLLs Start logging Repeat Start Logging Execute Command Repeat Execute Command Stop logging Stop Logging Stop Thread Close STSADM & Thread
  • 14. PowerShell vs STSADM - Performance PowerShell “Wrapped” STSADM to enable a feature on every SPSite Same command in SharePoint 2010 PowerShell: $rawdata = stsadm.exe -o enumsites -url $WebAppURL $sitexml = [XML]$rawdata $sitesxml.Sites | foreach-object{ $_.Site } | foreach-object{   stsadm -o activatefeature -url$_.url -filename $featureFileName          if( $lastexitcode -ne 0 ){             Write-Host “Failure:$lastexitcode " -Fore Red;             $failure = $true;          } } 12+ Hours (5300 SPSites) 30 Minutes (5300 SPSites) Get-SPSite –Limit ALL –WebApplication $WebAppNameorUrl |%{ Enable-SPFeature$FeatureIdOrName –url $_.Url }
  • 15.
  • 16.
  • 17. Getting Started with PowerShell (1) Execute a Cmdlet (2) Filter results using where clause (3) Add formatting instructions (4) Redirect output to new text file
  • 18. Getting Help in PowerShell
  • 19. Controlling PowerShell with variables, loops, logic, and functions
  • 20. Variables in PowerShell A variable is a place for you to store some value so you can revisit it later. All variables that you create begin with $ Ex: $my_first_variable= “Hello World” Variables Types Loosely typed variables $f = “bar” #implicitly typed as string $ary= 4,2,5,2 #typed as object[] Strongly typed variables [string]$f = “bar” Enhanced Types variables [xml]$d = “<a><b><c>c stuff 1</c><c>c stuff 2</c></b></a>”
  • 21. Looping in PowerShell Classic PowerShell Loop - For Loop $i = 10 For($j = 1; $j-lt $i; $j++){ Write-Host ”$j”; } - ForeachLoop $NumArray= (1,2,3,4,5,6,7,8,9,10)Foreach($Item in $NumArray) {$Item * 3} - While Loop $i =8 While ($i-le 96) { $i+=8; Write-Host$i; } - Do Until Loop $i = 7; do { $i+=7; Write-Host$i; } until ($i-gt 85) ForeachLoop with Pipeline Get-SPSite -Limit All | foreach { Remove-SPSite -identity $_.Id } $_ and is a variable that represents the current object
  • 22. Adding logic in PowerShell Logic is what enables you to do something at a specific point in the program. Statements If/ ElseIf/ Else Switch While Comparison Operators -eq/-ne -lt / -gt -le / -ge -like / -notlike -contains/-notcontains -replace …
  • 23. Working with PowerShell functions FunctionListRootDrive($DriveLetter) { Get-ChildItem–Path $DriveLetter} Function ListRootDrive { Get-ChildItem–Path $Args} FunctionListRootDrive { Get-ChildItem–Path $Args[0] } FunctionBlogUsers($SiteCollection) { Get-SPWeb-Site $SiteCollection| ForEach-Object { Write-Host “Site Title: “ $_.Title if ( $_.Title -eq “Blog” ) { Write-Host “Blog Users:” $_.Users }}}
  • 24.
  • 27. Alias: dir|% { $_.Name }
  • 30. Alias: dir|?{$_.Length –gt10}You can find these aliases with the Get-Aliascmdlet
  • 31. Creating your own PowerShell scripts
  • 32. Tools Notepad PowerShell Command Windows PowerShell Integrated Scripting Environment (ISE) PowerGUI - Download from powergui.org
  • 33. How to Create and Run a PowerShell Script The steps to create a script follow: Create the script in Notepad and save with a .PS1 file extension (hello.ps1). Run the script by entering the full path to the script (c:criptsello.ps1), or if it’s in the current directory (.ello.ps1). If the path to the script contains a space, enclose the full path in quotation marks and prefix the entire thing with an ampersand ("C:y scriptsello.ps1").
  • 34. Scripts and Execution Policy Local execution policy must be configured Scripts will not execute under default execution policy of restricted Scripts can execute under execution policy of unrestricted. Scripts that are not signed result in prompting user for permission to execute. Scripts can execute under execution policy of bypass. This mode suppresses prompting user for permission to execute.
  • 35. Editing Scripts using PowerShell ISE Supports Color-coding, IntelliSense and debugging Writing scripts here Run cmdlets or functions here Results
  • 37. The SharePoint PowerShell Snapin Explicitly load SharePoint PowerShell snap-in from console or script Implicitly load SharePoint PowerShell snap-in by using SharePoint 2010 Management Shell Begin using SharePoint Cmdlets
  • 38. Scheduling Your Scripts Sometimes commands need to be scheduled to run automatically PowerShell Scripts (.ps1) can be scheduled using Task Scheduler Just put the above command into a .bat or .cmd file and schedule it like you would normally schedule a script to be run with Task Scheduler.
  • 39. Demo – Series Of Scripts Run hello.ps1 script How to use PowerShell to create sites. How to use PowerShell to populate items in a List for testing, adding attachments How to use PowerShell to copy items from one list to another. How to use PowerShell to upload documents to a document libraries. How to use PowerShell to backup sites.
  • 40. Q&A
  • 41. Resources http://technet.microsoft.com/en-us/library/ee890105.aspx http://sharepointpsscripts.codeplex.com/ http://www.sharepointmonitor.com/2010/04/getting-started-powershell-in-sharepoint/ http://stackoverflow.com/questions/2143460/methods-to-convert-c-code-to-a-powershell-script http://www.techrepublic.com/blog/10things/10-reasons-why-you-should-learn-to-use-powershell/1073

Editor's Notes

  1. What =&gt; Why =&gt; Who =&gt; Where =&gt; When =&gt; How
  2. What is Shell?Working with a command-line interface, often called a shell, can be a daunting task. If you grew up working with DOS or Unix-based system, you&apos;ll feel right at home with PowerShell.If you&apos;re used to a computer that always presents you with a Graphical User Interface(GUI), then typing your commands into PowerShell may seem like going backward in time. After you become familiar with a command-line user interface, however, don&apos;t be surprised if you get fond of the speed, flexibility, and robustness you find there; you may get a hooked.What is PowerShell?Unix-like shellObject oriented.NETCommand lineScripting languageA single mindset for management of many different systems (e.g.: AD, Exchange, Windows)Extensible framework that can be embedded inside other applications
  3. Over the last few years, PowerShell scripting has begun to replace older DOS-style batch files and VBScript files as the preferred way to manage and automate administrative tasksCmdlets are callable functions Pipelining allow one Cmdlet to return an object as input to anotherPowerShell includes formatting features to display output using lists or tablesPowerShell is based on a provider-based model based on Snap-insSharePoint support added through Microsoft.SharePoint.Powershell..Snapin: Group of PowerShell functionality
  4. Previous version of WSS relies on STSADM.EXEUsed for command line administration and scriptingPSDrivesFileSystem Provider- access to the file systemMap to key SharePoint directoriesSTSADM via PowerShellExecute operations via the PowerShell hostIntegrate STSADM operations into the pipelineScripting via Object ModelAccess SharePoint objectsCreate reusable SharePoint-aware commandsCustom DevelopmentCmdLetsProvidersHost ApplicationsAutomated build and deploy: =&gt; Save time for Deploy/Test Cycle phases
  5. This is expensive! The first operation essentially iterates over every site twice—AND it has to start and stop the stsadm logging/process/etc for each feature activation!!The first took 12+ hours and NEVER FINISHED.The latter took roughly 30 minutes.
  6. Automation: using Task Scheduler for running Backup and Restore.Development:Testing: usingPowerShell for stress test
  7. The first example shows calling a Cmdlet that takes no parametersThe second example adds filtering by adding a Where commandWhere-Object {$_.name –eq &quot;F*&quot;}The syntax $_ refers to the object in question$_.name refers to the object&apos;s name property-eq is the operator for equalsThe third example adds in formatting instructionsThe last example redirects output so it is stored in a new text files.
  8. Get-Help cmdlet
  9. You can use aliases to save yourself the time and effort of typing cmdletsthat you use frequently. If you want to see all the aliases that PowerShell has mapped to specific cmdlets, use the Get-Alias cmdlet.
  10.  
  11. By default, PowerShell does not allow script to runAdministrator must change execution policy to enable script executionExecution Policy Settingsrestricted (default) – scripts prohibited from executingunrestricted - scripts can execute. Scripts that are signed can run with user interaction. Scripts that are not signed result in prompting user for permission to execute.bypass (developer mode) – scripts can execute and user interaction is suppressed.
  12. With the initial release of PowerShell, administrators and developers usually resorted to writing scripts with NotePad. PowerShell 2 provides a nice development environment for writing PowerShell scripts named the PowerShell Integrated Scripting Environment (ISE). When it comes t writing complex scripts with control of flow logic, it is really nice to be able to debug and single step through your code.
  13. Thisexample shows a PowerShell script which uses the New-SPSite cmdlet to create a new site. You should observe that the New-SPSite cmdlet returns a SPSite object which is then used to access the SPWeb object for the top-level site.
  14. SharePoint Server 2010 adds many Cmdlets for SharePoint administration through a Snap-in provider named Microsoft.SharePoint.PowerShell. The SharePoint cmdlets cannot be called until the SharePoint snap-in has been loaded.There are two common ways to load the SharePoint snap-inCall the Add-PSSnapin cmdlet and pass a parameter with the snap-in nameLaunch the PowerShell console using SharePoint Management Console. This link points to an XML file that loads the SharePoint snap-in in a declarative fashion.