Michael Blumenthal
PSC Group, LLC
No
Compiling!
No
Packaging!
Just Code &
Go!
• It’s Easy to Get Started!1
• Learn the PowerShell Syntax2
• Real World Examples3
• More Resources4
• Q&A5
Chapter 1
Windows Server 2003
• Download
Windows Server 2008
• Install
Server2008 R2 +
• Run (Add ISE)
• Upgrade to V4
Chapter 2
Symbols &
Keywords
Using the
SharePoint API
Creating and
Running Scripts
• Variables1
• Commands2
• Piping3
• Comparisons4
• Flow Control5
• Filtering6
Symbol Called Symbol Called
$ Dollar sign, money _ Underscore
# Hash, Pound [ ] Square Brackets
| Pipe, vertical bar . Dot...
• Case Insensitive, Dynamic typing
$foo
$true, $false, $profile, $null
$foo = “Hello, World”
1
Verb-Noun
Built-in, Extensible
Get-Help & Help
Get-Member
2
Output Of
Command 1
Input of
Command 2
3
4
Operator Meaning Operator Meaning
-eq Equals -le Less Than or
Equal To
-ne Not Equals -like Wildcard Match
-gt Greater T...
5
• For (Init;Test;Repeat) {Commands}
• for($i=1; $i -le 10; $i++) {Write-Host $i}For
• Foreach (Item in Collection) {Comm...
6
•Where {<Test>}Syntax
• V1&2:Dir | Where {$_.Name –
like
“B*”}
• V3:Dir | where Name –like B*
Example
• Getting an SPSite1
• Manipulating It2
• Cleaning Up3
SPField
SPListItem
SPList
SPWeb
SPWebApplication
SPFarm
Loading SharePoint DLLs
C:...14 or 15CONFIGPOWERSHELL
RegistrationSharePoint.ps1
SPWeb SPSite
Inline In Script
Chapter 3
• Bulk Create Sites1
• List Item CRUD2
• Create data for test cases3
• Associate Workflows with a
List
4
• Work across sit...
• Sync Wep App Properties8
• Install SharePoint9
• Repeatably Manage Content10
• Update Field Definitions11
• Edit MP3 Met...
.filename.ps1
Set-ExecutionPolicy
Unrestricted
Chapter 4
 PowerShell Product Team
Blog
 TechNet Script Center
 PowerShell in Action by
Bruce Payette
 CodePlex: PSBBs (mine)
 ...
It’s Easy to Get
Started!
Learn & Use the
PowerShell Syntax
More Resources
In Review…
• Michael Blumenthal
SharePoint Architect
PSC Group, LLC
• MBlumenthal@psclistens.com
• psclistens.com
• www.cspug.org
• T...
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators
Upcoming SlideShare
Loading in …5
×

SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators

405 views
298 views

Published on

An introduction to the PowerShell scripting language for SharePoint developers and administrators.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
405
On SlideShare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
32
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide
  • Every SharePoint Developer needs this!Fast and FlexibleGreat for Last Mile Problems. The MSFT standard for Scripting.
  • 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 or administrator!
  • 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”V4 is here
  • One is SharePoint aware, the other isn’t!
  • Does anyone have any other names for these?Victor Borge has his own take on these: http://www.youtube.com/watch?v=lF4qii8S3gw
  • Name that Language…Similar to @variables in SQL, apparently also Ruby, PHP.Arrays start at 0
  • Mention Aliases
  • Ask if anyone has unix scripting experience, and what they think of this.Can you imagine trying to do this in unix or vbscript?
  • Get-Help about_flow_controlMention that collections start at 0
  • Your mother doesn’t work here! You must clean up after yourself.
  • 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
  • Once used a choice column’s values instead of a CSV
  • Windows PowerShell in Action by Bruce Payette, V2Since then Hicks and Jones have written some good books too
  • http://technet.microsoft.com/en-us/scriptcenter/default
  • http://www.codeplex.com/psbb
  • Blog.blumenthalit.comBlog.blumenthalit.com/files/powershellhttp://blog.blumenthalit.com/blog/Lists/Posts/Post.aspx?ID=161, etc
  • 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
  • You owe it to yourself to try out PowerShell.It will make you a better developer or administrator!
  • SP24S053 Introduction to PowerShell for SharePoint Developers and Administrators

    1. 1. Michael Blumenthal PSC Group, LLC
    2. 2. No Compiling! No Packaging! Just Code & Go!
    3. 3. • It’s Easy to Get Started!1 • Learn the PowerShell Syntax2 • Real World Examples3 • More Resources4 • Q&A5
    4. 4. Chapter 1
    5. 5. Windows Server 2003 • Download Windows Server 2008 • Install Server2008 R2 + • Run (Add ISE) • Upgrade to V4
    6. 6. Chapter 2
    7. 7. Symbols & Keywords Using the SharePoint API Creating and Running Scripts
    8. 8. • Variables1 • Commands2 • Piping3 • Comparisons4 • Flow Control5 • Filtering6
    9. 9. 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$#|
    10. 10. • Case Insensitive, Dynamic typing $foo $true, $false, $profile, $null $foo = “Hello, World” 1
    11. 11. Verb-Noun Built-in, Extensible Get-Help & Help Get-Member 2
    12. 12. Output Of Command 1 Input of Command 2 3
    13. 13. 4 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)
    14. 14. 5 • 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
    15. 15. 6 •Where {<Test>}Syntax • V1&2:Dir | Where {$_.Name – like “B*”} • V3:Dir | where Name –like B* Example
    16. 16. • Getting an SPSite1 • Manipulating It2 • Cleaning Up3
    17. 17. SPField SPListItem SPList SPWeb SPWebApplication SPFarm
    18. 18. Loading SharePoint DLLs C:...14 or 15CONFIGPOWERSHELL RegistrationSharePoint.ps1
    19. 19. SPWeb SPSite Inline In Script
    20. 20. Chapter 3
    21. 21. • Bulk Create Sites1 • List Item CRUD2 • Create data for test cases3 • Associate Workflows with a List 4 • Work across site collections5 • Deployment Scripting6 • Identify files that won’t upload7
    22. 22. • Sync Wep App Properties8 • Install SharePoint9 • Repeatably Manage Content10 • Update Field Definitions11 • Edit MP3 Metadata, Make Flashcards 12
    23. 23. .filename.ps1 Set-ExecutionPolicy Unrestricted
    24. 24. Chapter 4
    25. 25.  PowerShell Product Team Blog  TechNet Script Center  PowerShell in Action by Bruce Payette  CodePlex: PSBBs (mine)  CodePlex:SPInstaller  Blog.BlumenthalIT.Net  SharePointJack.com • Jeff Hicks • Gary LaPointe • Raymond Mitchell • Todd Klindt • POSHCODE.ORG • get-spscripts.com • SPYam
    26. 26. It’s Easy to Get Started! Learn & Use the PowerShell Syntax More Resources In Review…
    27. 27. • Michael Blumenthal SharePoint Architect PSC Group, LLC • MBlumenthal@psclistens.com • psclistens.com • www.cspug.org • Twitter: @MichaelBL • SPYam Thank you for your time today.

    ×