intro to sharepoint + powershell
DESCRIPTION
You may have heard of PowerShell, but do you know what it’s capable of? Gone are the days of long, painful STSADM batch files – we have Windows PowerShell, and it’s here to stay.Learn how you can use Windows PowerShell both to perform simple one-off tasks as well as complex, bulk operations. Leveraging the Object Model gives Administrators and Developers the ability to do in a few lines of code what would’ve taken a lot more work (and probably a Developer or two) in the WSS platform.You’ll see how you can get started with PowerShell, and you will hopefully leave with not only a greater understanding of what PowerShell is – but what it is capable of and how you can start using it to automate tasks in your SharePoint 2010 environment.TRANSCRIPT
Getting Started with SharePoint + PowerShell
Ryan Dennis@SharePointRyan
www.SharePointRyan.com
Enter POWERSAT at checkout to save $50 on any training course.
www.TRAINSIGNAL.com
Learn PowerShell. 24/7, Anywhere.
SeeShell
http://www.codeowls.com/seeshell
Simple and EffectiveData Visualization
For PowerShell
Use Coupon CodePSSAT002
And save 20%
About The Speaker
Ryan Dennis, MCTS, MCPD, MCITPSenior SharePoint Engineer @ ICC Microsoft Virtual Technology Specialist (vTSP)
www.SharePointRyan.com
@SharePointRyan
linkedin.com/in/sharepointryan
Windows PowerShell
…is a task-based command-line shell and scripting language designed especially for Windows system administration
…has a task-based scripting language
…includes powerful object manipulation capabilities
…is built on the .NET Framework
Verb-Noun
PowerShell uses a Verb-Noun syntax for its Cmdlets• Get-Something
• Set-Something
• New-Something
• Remove-Something
Get-Command & Get-Help
• While you can do a lot of the same things as the typical command prompt, use Get-Command to see available commands
• Use Get-Help <cmdlet> to get help information for a cmdlet
Using PowerShell Profiles
• PowerShell uses 2 profiles, a user specific profile and a machine-wide profile…
• Use profiles to pre-load scripts, functions, environmental variables, shell settings, aliases, etc.
Script Editors & Tools
• Notepad.exe (Lame)• Notepad++ (Less Lame)• Windows PowerShell ISE (Pretty
Good - includes IntelliSense, Syntax highlighting)
• Quest PowerGUI (Awesome – Adds advanced debugging, and other cool things – don’t worry, I’ll show you!)
• Others…
SharePoint 2010 Cmdlets
• 500+ Cmdlets…
• MUCH better than STSADM.exe…
• Can automate complete installations and configurations…
• Still doesn’t answer every scenario, leaving gaps in functionality…– Example: Get, New and Remove
SharePoint Groups – no cmdlet, easy to write a custom function though…
DEMONSTRATION
Creating a SharePoint Web Application using out-of-the-box PowerShell Cmdlets
Demo Recap
• Used New-SPWebApplication to create a new SharePoint Web Application…
• Stored the SPWebApplication object into the $webapp variable
• Used Get-Member to view Methods and Properties associated with the Web Application
DEMONSTRATION TWO
Creating a SharePoint Site Collection using out-of-the-box PowerShell Cmdlets
Demo Recap
• Used New-SPSite to create a new SharePoint Site Collection…
• Stored the SPSite object into the $site variable• Created a $web variable from $site.rootweb• Used the $web variable to change the Site
Title using the SP Object Model• Used Get-History and Pipeline to create a
simple script from our command history…• Cool right, but what if we could make this
reusable??? (Hint: we can)
Extending PowerShell with Scripts and Functions
• PowerShell Scripts have .ps1 file extension…
• Scripts and functions behave similarly if not identically, but functions are more reusable…
• Scripts can reference functions and cmdlets…
• Functions can include other functions within them and can also reference cmdlets…
DEMONSTRATION THREE
Using what we already learned and making it better.
Demo Recap
• Used the following cmdlets in conjunction with the pipeline to automagically build a function based on what we did in our first demonstration:– Get-History– Select-Object– Out-File
• Used Quest PowerGUI to edit our function by adding Parameters, eliminating hard-coded values…
• Added comment-based help from PowerGUI Snippet…
• Tried out our cool, new function…
The Power IS in the Shell, Use it Wisely!
• PowerShell is VERY powerful, be aware of memory issues...
• Use dispose() method for Site and Web objects, or better yet…
• Use Start-SPAssignment –Global to capture all objects in the Global store, then use Stop-SPAssignment –Global to dispose of all objects…
Get-Resources
1. TechNet for general PowerShell information…
2. The Hey, Scripting Guy! blog3. Get-SPScripts.com4. Gary Lapointe5. Get-Help in a PowerShell window…6. SharePointRyan.com (yes, my blog)…
Got-Questions -?
Ryan Dennis, MCTS, MCPD, MCITPSenior SharePoint Engineer @ ICC Microsoft Virtual Technology Specialist (vTSP)
www.SharePointRyan.com
@SharePointRyan
linkedin.com/in/sharepointryan