SlideShare una empresa de Scribd logo
1 de 59
Introduction to PowerShell
for SharePoint Developers and
Administrators
SIA 101
Michael Blumenthal
PSC Group, LLC
2
Who is Michael Blumenthal?
Sr. Solution Architect
at PSC Group
CSPUG Co-Leader
INETA Champ 2010-2013
18 years in IT Consulting
10 years working with
SharePoint (2003,2007,2010, 2013)
3
This is about you
Version of SharePoint?
Admin, Developer, Both, Other?
PowerShell experience?
SharePoint experience?
Unix experience?
Scripting experience?
4
No
Compiling!
No
Packaging!
Just Code &
Go!
Why PowerShell?
5
PowerShell puts the SharePoint
Engine at your fingertips!
• It’s Easy to Get Started!1
• Learn the PowerShell Syntax2
• Real World Examples3
• More Resources4
• Q&A & Raffle5
6
Chapter 1
Getting Started with PowerShell
Windows Server 2003
• Download
Windows Server 2008
• Install
Server2008 R2, 2012, Win8
• Run (Add ISE)
8
9
10
11
PowerShell V3 ISE
12
POSH vs the SharePoint Mgmt Shell
13
Chapter 2
Learn to use PowerShellwith SharePoint!
Symbols &
Keywords
Using the
SharePoint API
Creating and
Running Scripts
15
Symbols, Keywords, and Syntax! Oh
My!
• Variables1
• Commands2
• Piping3
• Comparisons4
• Flow Control5
• Filtering6
16
Punctuation Pronunciation
Symbol Called Symbol Called
$ Dollar sign, money _ Underscore
# Hash, Pound [ ] Square Brackets
| Pipe, vertical bar . Dot, point, period
{ } Curly braces < > Angle Brackets
“ Double Quote, tick - Dash, hyphen, minus
: Colon % Percent sign
( ) Parentheses ; Semi-colon
+ Plus = Equals, is
! Bang, not /,  Slash, backslash
1$#|
17
Variables begin with a $
• Case Insensitive, Dynamic typing
$foo
$true, $false, $profile, $null
$foo = “Hello, World”
1
18
19
Commands are called cmdlets.
Verb-Noun
Built-in, Extensible
Get-Help & Help
Get-Member
2
20
21
The Power of Piping!
Output Of
Command 1
Input of
Command 2
3
Example
Making Comparisons4
Operator Meaning Operator Meaning
-eq Equals -le Less Than or
Equal To
-ne Not Equals -like Wildcard Match
-gt Greater Than -notlike Not (Wildcard
Match)
-ge Greater Than
or Equal To
-match Reg. Exp. Match
-lt Less Than -notmatch Not (Reg. Exp.
Match)
24
Example
25
Taking Control of the Flow5
• For (Init;Test;Repeat) {Commands}
• for($i=1; $i -le 10; $i++) {Write-Host $i}For
• Foreach (Item in Collection) {Commands}
• Foreach ($web in $site.AllWebs) {$web.Title}ForEach
• If (Test) {Commands}
• if ($web.Title –ne “”) {Write-Host $web.Title}If
• While (Condition){Commands}
• while($val -ne 3){$val++; Write-Host $val}While
Example
27
Where-Object6
•Where {<Test>}Syntax
• V1&2:Dir | Where {$_.Name –like
“B*”}
• V3:Dir | where Name –like B*
Example
28
Using the SharePoint API
•Getting an SPSite1
•Manipulating It2
•Cleaning Up3
29
Highlights from the SharePoint
Object Model
SPField
SPListItem
SPList
SPWeb
SPWebApplication
SPFarm
30
Loading SharePoint Cmdlets
Even in MOSS 2007:
[void][System.Reflection.Assembly]::
LoadWithPartialName("Microsoft.SharePoint")
Loading SharePoint DLLs
C:...14 or 15CONFIGPOWERSHELL
RegistrationSharePoint.ps1
31
A Word About Memory Management
SPWeb SPSite
Inline In Script
32
33
Chapter 3
34
Real World Examples
Check the Farm Version
Check Versioning on all document Libraries
Create List Items
Export Web App Properties to a file
Bulk Site Creation
35
What’s your SP2010 Version?
PS C:UsersAdministrator> $(get-
SPFarm).BuildVersion
Major Minor Build Revision
----- ----- ----- --------
14 0 6109 5002
36
Get a Site and Explore it!
$site = get-spsite http://server/path
THEN
$site
37
38
Check Doc Lib Versioning Settings
function global:show-all-doclibs ($web)
{$web.Lists | where-object {($_.Hidden -ne $true)
-and ($_.BaseType -eq "DocumentLibrary")} }
function global:show-all-doclib-versettings
($web)
{show-all-doclibs ($web) |select-object -property
Title, EnableVersioning, MajorVersionLimit,
EnableMinorVersions,MajorWithMinorVersionsLimit
,forceCheckout}
$site = get-spsite “http://server/path”
show-all-doclib-versettings $site.RootWeb
39
40
Practical Uses
• Bulk Create Sites1
• List Item CRUD2
•Create data for test cases3
• Associate Workflows with a List4
•Work across site collections5
• Deployment Scripting6
• Identify files that won’t upload7
41
More Practical Uses
• Sync Wep App Properties8
• Install SharePoint9
• Repeatably Manage Content10
• Update Field Definitions11
• Edit MP3 Metadata, Make Flashcards12
42
What’s your SharePoint Version?
PS C:UsersAdministrator> $(get-
SPFarm).BuildVersion
Major Minor Build Revision
----- ----- ----- --------
14 0 6109 5002
43
Create a List Item
44
Audio Alerts
Stick this at the end of your long running script:
$Voice = new-object -com SAPI.SpVoice
$Voice.Speak(“Deployment is done!")
45
Executing Scripts
.filename.ps1
Set-ExecutionPolicy
Unrestricted
46
Bulk Site Creation
Site Definitions in V. Studio
Not an answer by themselves
Define site content
Intended for reuse
Mismatch to one time need
CAML and PITA
Harder: Making it data driven
Change Site Def -> Recreate Site
PowerShell & Excel & UI
Well suited for one time “blow
in’s”
Define the site template in the
UI or use standard
Save as a template
Even pub sites - sometimes
PowerShell has easy loops
Data driven from a CSV
Changes -> Mod Scripts
47
The PowerShell Solution
Read the list of sites from CSV
Loop:
Create Site
Configure Site
Turn on Features
Set Master Pages, Welcome Page
Hide Libraries, set versioning
Adjust Navigation
Add Lists, Libraries, Pages, Web parts, etc
Loop again & again if needed – iterative!
48
Chapter 4
Resources
Books & Blogs
People & Places
50
51
52
53
54
55
56
57
Resources Summary
MSFT
PowerShell Product Team Blog
Script Center
Community
Various Books
CodePlex: PSBBs (mine), CodePlex:SPInstaller
Blog.BlumenthalIT.Net
SharePointJack.com
Jeff Hicks , Gary LaPointe, Raymond Mitchell,
Todd Klindt, POSHCODE.ORG, get-spscripts.com
SPYam
58
Script something today!
It’s Easy to Get
Started!
Learn & Use the
PowerShell Syntax
More Resources
In Review…
59
Questions
& Raffle
• Michael Blumenthal
SharePoint Architect
PSC Group, LLC
• MBlumenthal@psclistens.com
• psclistens.com
• www.cspug.org
• Twitter: @MichaelBL
• SPYam
Thank you for your time today.

Más contenido relacionado

La actualidad más candente

What's new in xamarin.android, Jonathan Pryor
What's new in xamarin.android, Jonathan PryorWhat's new in xamarin.android, Jonathan Pryor
What's new in xamarin.android, Jonathan Pryor
Xamarin
 

La actualidad más candente (20)

DevOp with Me!
DevOp with Me!DevOp with Me!
DevOp with Me!
 
What's new in xamarin.android, Jonathan Pryor
What's new in xamarin.android, Jonathan PryorWhat's new in xamarin.android, Jonathan Pryor
What's new in xamarin.android, Jonathan Pryor
 
Automated Deployments with Ansible
Automated Deployments with AnsibleAutomated Deployments with Ansible
Automated Deployments with Ansible
 
PuppetConf 2016: Best Practices for Puppet in the Cloud – Randall Hunt, Amazo...
PuppetConf 2016: Best Practices for Puppet in the Cloud – Randall Hunt, Amazo...PuppetConf 2016: Best Practices for Puppet in the Cloud – Randall Hunt, Amazo...
PuppetConf 2016: Best Practices for Puppet in the Cloud – Randall Hunt, Amazo...
 
Zero Code Multi-Cloud Automation with Ansible and Terraform
Zero Code Multi-Cloud Automation with Ansible and TerraformZero Code Multi-Cloud Automation with Ansible and Terraform
Zero Code Multi-Cloud Automation with Ansible and Terraform
 
PowerShell for SharePoint Developers
PowerShell for SharePoint DevelopersPowerShell for SharePoint Developers
PowerShell for SharePoint Developers
 
Immutable Infrastructure with Packer Ansible and Terraform
Immutable Infrastructure with Packer Ansible and TerraformImmutable Infrastructure with Packer Ansible and Terraform
Immutable Infrastructure with Packer Ansible and Terraform
 
You don’t need DTAP + Backbase implementation - Amsterdam 17-12-2015
You don’t need DTAP + Backbase implementation - Amsterdam 17-12-2015You don’t need DTAP + Backbase implementation - Amsterdam 17-12-2015
You don’t need DTAP + Backbase implementation - Amsterdam 17-12-2015
 
Jfokus 2015 - Immutable Server generation: the new App Deployment
Jfokus 2015 - Immutable Server generation: the new App DeploymentJfokus 2015 - Immutable Server generation: the new App Deployment
Jfokus 2015 - Immutable Server generation: the new App Deployment
 
Apex Liberation: The Evolution of FlexQueues
Apex Liberation: The Evolution of FlexQueuesApex Liberation: The Evolution of FlexQueues
Apex Liberation: The Evolution of FlexQueues
 
Packer, Terraform, Ansible avec Azure
Packer, Terraform, Ansible avec AzurePacker, Terraform, Ansible avec Azure
Packer, Terraform, Ansible avec Azure
 
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
Chef vs Puppet vs Ansible vs SaltStack | Configuration Management Tools Compa...
 
Architecting for continuous delivery (33rd Degree)
Architecting for continuous delivery (33rd Degree)Architecting for continuous delivery (33rd Degree)
Architecting for continuous delivery (33rd Degree)
 
CPAN Dependency Heaven
CPAN Dependency HeavenCPAN Dependency Heaven
CPAN Dependency Heaven
 
Alfresco javascript api - Alfresco Devcon 2018
Alfresco javascript api - Alfresco Devcon 2018Alfresco javascript api - Alfresco Devcon 2018
Alfresco javascript api - Alfresco Devcon 2018
 
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In CodeIntroduction to Chef: Automate Your Infrastructure by Modeling It In Code
Introduction to Chef: Automate Your Infrastructure by Modeling It In Code
 
Mete Atamel
Mete AtamelMete Atamel
Mete Atamel
 
Immutable Server generation: The new App Deployment
Immutable Server generation: The new App DeploymentImmutable Server generation: The new App Deployment
Immutable Server generation: The new App Deployment
 
Improve Magento Performance
Improve Magento PerformanceImprove Magento Performance
Improve Magento Performance
 
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
Chef Fundamentals Training Series Module 3: Setting up Nodes and Cookbook Aut...
 

Destacado

Destacado (6)

Basic powershell scripts
Basic powershell scriptsBasic powershell scripts
Basic powershell scripts
 
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
 
Best practices and tools for PowerShell and SharePoint Scripting SharePointFe...
Best practices and tools for PowerShell and SharePoint Scripting SharePointFe...Best practices and tools for PowerShell and SharePoint Scripting SharePointFe...
Best practices and tools for PowerShell and SharePoint Scripting SharePointFe...
 
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram ExperienceSharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
 
Chris O'Brien - Modern SharePoint development: techniques for moving code off...
Chris O'Brien - Modern SharePoint development: techniques for moving code off...Chris O'Brien - Modern SharePoint development: techniques for moving code off...
Chris O'Brien - Modern SharePoint development: techniques for moving code off...
 
An Introduction to Windows PowerShell
An Introduction to Windows PowerShellAn Introduction to Windows PowerShell
An Introduction to Windows PowerShell
 

Similar a Introduction to PowerShell for SharePoint Admins and Developers - SharePoint Fest Chicago 2013 SIA101

Power shell for sp admins
Power shell for sp adminsPower shell for sp admins
Power shell for sp admins
Rick Taylor
 
PowerShellForDBDevelopers
PowerShellForDBDevelopersPowerShellForDBDevelopers
PowerShellForDBDevelopers
Bryan Cafferky
 
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
SharePoint 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 Powershell
SharePoint Saturday NY
 
Automating PowerShell with SharePoint
Automating PowerShell with SharePointAutomating PowerShell with SharePoint
Automating PowerShell with SharePoint
Talbott Crowell
 

Similar a Introduction to PowerShell for SharePoint Admins and Developers - SharePoint Fest Chicago 2013 SIA101 (20)

SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
SPugPt Meeting 35: Manage govern and drive adoption of share point online wit...
 
Powershell to the People #suguk
Powershell to the People #sugukPowershell to the People #suguk
Powershell to the People #suguk
 
Windows Server 2008 (PowerShell Scripting Uygulamaları)
Windows Server 2008 (PowerShell Scripting Uygulamaları)Windows Server 2008 (PowerShell Scripting Uygulamaları)
Windows Server 2008 (PowerShell Scripting Uygulamaları)
 
Power shell for sp admins
Power shell for sp adminsPower shell for sp admins
Power shell for sp admins
 
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
 
NZ Code Camp 2011 PowerShell + SharePoint
NZ Code Camp 2011 PowerShell + SharePointNZ Code Camp 2011 PowerShell + SharePoint
NZ Code Camp 2011 PowerShell + SharePoint
 
PowerShellForDBDevelopers
PowerShellForDBDevelopersPowerShellForDBDevelopers
PowerShellForDBDevelopers
 
PowerShell Introduction to Administering SharePoint On-Premises & O365
PowerShell Introduction to Administering SharePoint On-Premises & O365PowerShell Introduction to Administering SharePoint On-Premises & O365
PowerShell Introduction to Administering SharePoint On-Premises & O365
 
VMworld 2016: Getting Started with PowerShell and PowerCLI for Your VMware En...
VMworld 2016: Getting Started with PowerShell and PowerCLI for Your VMware En...VMworld 2016: Getting Started with PowerShell and PowerCLI for Your VMware En...
VMworld 2016: Getting Started with PowerShell and PowerCLI for Your VMware En...
 
Sql Server & PowerShell
Sql Server & PowerShellSql Server & PowerShell
Sql Server & PowerShell
 
Operacion Guinda 2
Operacion Guinda 2Operacion Guinda 2
Operacion Guinda 2
 
Introduction to PowerShell for SharePoint Admins and Developers
Introduction to PowerShell for SharePoint Admins and DevelopersIntroduction to PowerShell for SharePoint Admins and Developers
Introduction to PowerShell for SharePoint Admins and Developers
 
Standardizing and Managing Your Infrastructure - MOSC 2011
Standardizing and Managing Your Infrastructure - MOSC 2011Standardizing and Managing Your Infrastructure - MOSC 2011
Standardizing and Managing Your Infrastructure - MOSC 2011
 
PowerShell: Automation for everyone
PowerShell: Automation for everyonePowerShell: Automation for everyone
PowerShell: Automation for everyone
 
PowerShell: Automation for Everyone
PowerShell: Automation for EveryonePowerShell: Automation for Everyone
PowerShell: Automation for Everyone
 
Intro to SharePoint + PowerShell
Intro to SharePoint + PowerShellIntro to SharePoint + PowerShell
Intro to SharePoint + 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
 
WinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release PipelinesWinOps Conf 2016 - Michael Greene - Release Pipelines
WinOps Conf 2016 - Michael Greene - Release Pipelines
 
Automating PowerShell with SharePoint
Automating PowerShell with SharePointAutomating PowerShell with SharePoint
Automating PowerShell with SharePoint
 

Más de Michael Blumenthal (Microsoft MVP)

Más de Michael Blumenthal (Microsoft MVP) (20)

Tracking what's new and next for Teams in Your tenant.pptx
Tracking what's new and next for Teams in Your tenant.pptxTracking what's new and next for Teams in Your tenant.pptx
Tracking what's new and next for Teams in Your tenant.pptx
 
Collaboration Fundamentals - ALI Modern Intranets May 2023
Collaboration Fundamentals - ALI Modern Intranets May 2023Collaboration Fundamentals - ALI Modern Intranets May 2023
Collaboration Fundamentals - ALI Modern Intranets May 2023
 
Hidden Gems of Office - Teams Day Online Sept 2022
Hidden Gems of Office - Teams Day Online Sept 2022Hidden Gems of Office - Teams Day Online Sept 2022
Hidden Gems of Office - Teams Day Online Sept 2022
 
So You Think You Have OneDrive Deployed.pptx
So You Think You Have OneDrive Deployed.pptxSo You Think You Have OneDrive Deployed.pptx
So You Think You Have OneDrive Deployed.pptx
 
Toastmasters Word of the Day - Feghoot.pptx
Toastmasters Word of the Day - Feghoot.pptxToastmasters Word of the Day - Feghoot.pptx
Toastmasters Word of the Day - Feghoot.pptx
 
10 Tips to Make You A Better Speaker.pptx
10 Tips to Make You A Better Speaker.pptx10 Tips to Make You A Better Speaker.pptx
10 Tips to Make You A Better Speaker.pptx
 
Hidden Gems of Microsoft Office
Hidden Gems of Microsoft OfficeHidden Gems of Microsoft Office
Hidden Gems of Microsoft Office
 
October 2020 Office 365 Adoption Users Group meeting agenda
October 2020 Office 365 Adoption Users Group meeting agendaOctober 2020 Office 365 Adoption Users Group meeting agenda
October 2020 Office 365 Adoption Users Group meeting agenda
 
August 2020 Office 365 Adoption Users Group meeting agenda
August 2020 Office 365 Adoption Users Group meeting agendaAugust 2020 Office 365 Adoption Users Group meeting agenda
August 2020 Office 365 Adoption Users Group meeting agenda
 
Lessons Learned while Deploying OneDrive Sync
Lessons Learned while Deploying OneDrive SyncLessons Learned while Deploying OneDrive Sync
Lessons Learned while Deploying OneDrive Sync
 
2020 July Office 365 AI news for the Midwest AI Group (MAIG)
2020 July Office 365 AI news for the Midwest AI Group (MAIG)2020 July Office 365 AI news for the Midwest AI Group (MAIG)
2020 July Office 365 AI news for the Midwest AI Group (MAIG)
 
June 2020 Office 365 Adoption User Group meeting agenda
June 2020 Office 365 Adoption User Group meeting agendaJune 2020 Office 365 Adoption User Group meeting agenda
June 2020 Office 365 Adoption User Group meeting agenda
 
May 2020 Office 365 Adoption User Group Meeting Agenda
May 2020 Office 365 Adoption User Group Meeting AgendaMay 2020 Office 365 Adoption User Group Meeting Agenda
May 2020 Office 365 Adoption User Group Meeting Agenda
 
M365 The Tour Israel: Deploying OneDrive Sync
M365 The Tour Israel: Deploying OneDrive SyncM365 The Tour Israel: Deploying OneDrive Sync
M365 The Tour Israel: Deploying OneDrive Sync
 
April 2020 Office 365 Adoption Users Group meeting agenda
April 2020 Office 365 Adoption Users Group meeting agendaApril 2020 Office 365 Adoption Users Group meeting agenda
April 2020 Office 365 Adoption Users Group meeting agenda
 
Overview of Office 365: The Elephant in the Room
Overview of Office 365: The Elephant in the RoomOverview of Office 365: The Elephant in the Room
Overview of Office 365: The Elephant in the Room
 
Deploying OneDrive Sync
Deploying OneDrive SyncDeploying OneDrive Sync
Deploying OneDrive Sync
 
February 2020 Office 365 Adoption Users Group Sponsor Slides
February 2020 Office 365 Adoption Users Group Sponsor SlidesFebruary 2020 Office 365 Adoption Users Group Sponsor Slides
February 2020 Office 365 Adoption Users Group Sponsor Slides
 
February 2020 Office 365 Adoption Users Group meeting agenda
February 2020 Office 365 Adoption Users Group meeting agendaFebruary 2020 Office 365 Adoption Users Group meeting agenda
February 2020 Office 365 Adoption Users Group meeting agenda
 
January 2020 Office 365 Adoption Users Group (Chicagoland Chapter) Meeting
January 2020 Office 365 Adoption Users Group (Chicagoland Chapter) MeetingJanuary 2020 Office 365 Adoption Users Group (Chicagoland Chapter) Meeting
January 2020 Office 365 Adoption Users Group (Chicagoland Chapter) Meeting
 

Último

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 

Último (20)

Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Introduction to PowerShell for SharePoint Admins and Developers - SharePoint Fest Chicago 2013 SIA101

  • 1. Introduction to PowerShell for SharePoint Developers and Administrators SIA 101 Michael Blumenthal PSC Group, LLC
  • 2. 2 Who is Michael Blumenthal? Sr. Solution Architect at PSC Group CSPUG Co-Leader INETA Champ 2010-2013 18 years in IT Consulting 10 years working with SharePoint (2003,2007,2010, 2013)
  • 3. 3 This is about you Version of SharePoint? Admin, Developer, Both, Other? PowerShell experience? SharePoint experience? Unix experience? Scripting experience?
  • 5. 5 PowerShell puts the SharePoint Engine at your fingertips! • It’s Easy to Get Started!1 • Learn the PowerShell Syntax2 • Real World Examples3 • More Resources4 • Q&A & Raffle5
  • 7. Getting Started with PowerShell Windows Server 2003 • Download Windows Server 2008 • Install Server2008 R2, 2012, Win8 • Run (Add ISE)
  • 8. 8
  • 9. 9
  • 10. 10
  • 12. 12 POSH vs the SharePoint Mgmt Shell
  • 14. Learn to use PowerShellwith SharePoint! Symbols & Keywords Using the SharePoint API Creating and Running Scripts
  • 15. 15 Symbols, Keywords, and Syntax! Oh My! • Variables1 • Commands2 • Piping3 • Comparisons4 • Flow Control5 • Filtering6
  • 16. 16 Punctuation Pronunciation Symbol Called Symbol Called $ Dollar sign, money _ Underscore # Hash, Pound [ ] Square Brackets | Pipe, vertical bar . Dot, point, period { } Curly braces < > Angle Brackets “ Double Quote, tick - Dash, hyphen, minus : Colon % Percent sign ( ) Parentheses ; Semi-colon + Plus = Equals, is ! Bang, not /, Slash, backslash 1$#|
  • 17. 17 Variables begin with a $ • Case Insensitive, Dynamic typing $foo $true, $false, $profile, $null $foo = “Hello, World” 1
  • 18. 18
  • 19. 19 Commands are called cmdlets. Verb-Noun Built-in, Extensible Get-Help & Help Get-Member 2
  • 20. 20
  • 21. 21 The Power of Piping! Output Of Command 1 Input of Command 2 3
  • 23. Making Comparisons4 Operator Meaning Operator Meaning -eq Equals -le Less Than or Equal To -ne Not Equals -like Wildcard Match -gt Greater Than -notlike Not (Wildcard Match) -ge Greater Than or Equal To -match Reg. Exp. Match -lt Less Than -notmatch Not (Reg. Exp. Match)
  • 25. 25 Taking Control of the Flow5 • For (Init;Test;Repeat) {Commands} • for($i=1; $i -le 10; $i++) {Write-Host $i}For • Foreach (Item in Collection) {Commands} • Foreach ($web in $site.AllWebs) {$web.Title}ForEach • If (Test) {Commands} • if ($web.Title –ne “”) {Write-Host $web.Title}If • While (Condition){Commands} • while($val -ne 3){$val++; Write-Host $val}While
  • 27. 27 Where-Object6 •Where {<Test>}Syntax • V1&2:Dir | Where {$_.Name –like “B*”} • V3:Dir | where Name –like B* Example
  • 28. 28 Using the SharePoint API •Getting an SPSite1 •Manipulating It2 •Cleaning Up3
  • 29. 29 Highlights from the SharePoint Object Model SPField SPListItem SPList SPWeb SPWebApplication SPFarm
  • 30. 30 Loading SharePoint Cmdlets Even in MOSS 2007: [void][System.Reflection.Assembly]:: LoadWithPartialName("Microsoft.SharePoint") Loading SharePoint DLLs C:...14 or 15CONFIGPOWERSHELL RegistrationSharePoint.ps1
  • 31. 31 A Word About Memory Management SPWeb SPSite Inline In Script
  • 32. 32
  • 34. 34 Real World Examples Check the Farm Version Check Versioning on all document Libraries Create List Items Export Web App Properties to a file Bulk Site Creation
  • 35. 35 What’s your SP2010 Version? PS C:UsersAdministrator> $(get- SPFarm).BuildVersion Major Minor Build Revision ----- ----- ----- -------- 14 0 6109 5002
  • 36. 36 Get a Site and Explore it! $site = get-spsite http://server/path THEN $site
  • 37. 37
  • 38. 38 Check Doc Lib Versioning Settings function global:show-all-doclibs ($web) {$web.Lists | where-object {($_.Hidden -ne $true) -and ($_.BaseType -eq "DocumentLibrary")} } function global:show-all-doclib-versettings ($web) {show-all-doclibs ($web) |select-object -property Title, EnableVersioning, MajorVersionLimit, EnableMinorVersions,MajorWithMinorVersionsLimit ,forceCheckout} $site = get-spsite “http://server/path” show-all-doclib-versettings $site.RootWeb
  • 39. 39
  • 40. 40 Practical Uses • Bulk Create Sites1 • List Item CRUD2 •Create data for test cases3 • Associate Workflows with a List4 •Work across site collections5 • Deployment Scripting6 • Identify files that won’t upload7
  • 41. 41 More Practical Uses • Sync Wep App Properties8 • Install SharePoint9 • Repeatably Manage Content10 • Update Field Definitions11 • Edit MP3 Metadata, Make Flashcards12
  • 42. 42 What’s your SharePoint Version? PS C:UsersAdministrator> $(get- SPFarm).BuildVersion Major Minor Build Revision ----- ----- ----- -------- 14 0 6109 5002
  • 44. 44 Audio Alerts Stick this at the end of your long running script: $Voice = new-object -com SAPI.SpVoice $Voice.Speak(“Deployment is done!")
  • 46. 46 Bulk Site Creation Site Definitions in V. Studio Not an answer by themselves Define site content Intended for reuse Mismatch to one time need CAML and PITA Harder: Making it data driven Change Site Def -> Recreate Site PowerShell & Excel & UI Well suited for one time “blow in’s” Define the site template in the UI or use standard Save as a template Even pub sites - sometimes PowerShell has easy loops Data driven from a CSV Changes -> Mod Scripts
  • 47. 47 The PowerShell Solution Read the list of sites from CSV Loop: Create Site Configure Site Turn on Features Set Master Pages, Welcome Page Hide Libraries, set versioning Adjust Navigation Add Lists, Libraries, Pages, Web parts, etc Loop again & again if needed – iterative!
  • 50. 50
  • 51. 51
  • 52. 52
  • 53. 53
  • 54. 54
  • 55. 55
  • 56. 56
  • 57. 57 Resources Summary MSFT PowerShell Product Team Blog Script Center Community Various Books CodePlex: PSBBs (mine), CodePlex:SPInstaller Blog.BlumenthalIT.Net SharePointJack.com Jeff Hicks , Gary LaPointe, Raymond Mitchell, Todd Klindt, POSHCODE.ORG, get-spscripts.com SPYam
  • 58. 58 Script something today! It’s Easy to Get Started! Learn & Use the PowerShell Syntax More Resources In Review…
  • 59. 59 Questions & Raffle • Michael Blumenthal SharePoint Architect PSC Group, LLC • MBlumenthal@psclistens.com • psclistens.com • www.cspug.org • Twitter: @MichaelBL • SPYam Thank you for your time today.

Notas del editor

  1. Every SharePoint Developer needs this!Fast and FlexibleGreat for LastMile Problems. New MSFT std for Scripting
  2. Who would like another tool in their toolbox, one that will help them with SharePoint, but also with many other things? How about the swiss army knife of tools?It will make you a better developer!
  3. Who here already has installed and PowerShell? Who’s using Server 2003? 2008?Win 2003: http://www.microsoft.com/windowsserver2003/technologies/management/powershell/download.mspxWin 2008 – It’s an OS Feature – “servermanagercmd –install PowerShell”V3 is here
  4. One is SharePoint aware, the other isn’t!
  5. Does anyone have any other names for these?Victor Borge has his own take on these: http://www.youtube.com/watch?v=lF4qii8S3gw
  6. Name that Language…Similar to @variables in SQL, apparently also Ruby, PHP.Arrays start at 0
  7. Mention Aliases
  8. Ask if anyone has unix scripting experience, and what they think of this.Can you imagine trying to do this in unix or vbscript?
  9. Get-Help about_flow_controlMention that collections start at 0
  10. Ask if anyone has unix scripting experience, and what they think of this.Can you imagine trying to do this in unix or vbscript?
  11. If you are familiar with these objects, raise your hand.
  12. Your mother doesn’t work here! You must clean up after yourself.
  13. http://sharepoint.microsoft.com/blog/Pages/BlogPost.aspx?PageType=4&amp;ListId={72C1C85B-1D2D-4A4A-90DE-CA74A7808184}&amp;pID=524http://msdn.microsoft.com/en-us/library/ee557362.aspxSee Assignment collections - http://technet.microsoft.com/en-us/library/ff607664.aspx
  14. Michael
  15. Once used a choice column’s values instead of a CSV
  16. Windows PowerShell in Action by Bruce Payette, V2Since then Hicks and Jones have written some good ones
  17. http://technet.microsoft.com/en-us/scriptcenter/default
  18. http://www.codeplex.com/psbb
  19. Blog.blumenthalit.comBlog.blumenthalit.com/files/powershellhttp://blog.blumenthalit.com/blog/Lists/Posts/Post.aspx?ID=161, etc
  20. Also:PoshCode.OrgTechNet Script Center http://www.microsoft.com/technet/scriptcenter/default.mspx MSDN SharePoint Developer Center http://msdn.microsoft.com/en-us/office/aa905503.aspx Zach Rosenfield’s Blog - http://sharepoint.microsoft.com/blogs/zach/default.aspxhttp://blog.falchionconsulting.com/http://www.powergui.org/downloads.jspahttp://thepowershellguy.com/blogs/posh/pages/powertab.aspx
  21. You owe it to yourself to try out PowerShell.It will make you a better developer!