Spsatx slides (widescreen)

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
…

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.

In this demo filled session, 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 or 2013 environment.

Transcript

1.
The Power is in the Shell, use it wisely! Get-Command –Module Microsoft.SharePoint.PowerShell Ryan Dennis | MCTS, MCPD, MCITP SharePoint Solutions Architect, Focal Point Solutions

2.
THANK YOU FOR BEING A PART OF SHAREPOINTSATURDAY AUSTIN!• Please turn off all electronic devices or set them to vibrate• If you must take a phone call, please do so in the hall• Wi-Fi is available, you will need your Guest ID/password (at registration desk)• Feel free to tweet and blog during sessions. Remember to follow @SPSATX and tag #SPSATX in your tweets! SharePoint Saturday Austin is hosted by the Austin SharePoint User Group (@AustinSPUG) 2 | SharePoint Saturday Austin 2013

8.
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 – Get-Command –Module Microsoft.SharePoint.PowerShell will show you all SharePoint Cmdlets• Use Get-Help <cmdlet> to get help information for a cmdlet – Get-Help <cmdlet> -Examples will show you examples for a cmdlet Quick Tip! Add Help to your scripts and functions! 8 | SharePoint Saturday Austin 2013

12.
POWERSHELL WEB ACCESS & SHAREPOINT 2013• Pros: – Allows administrators to work with SP2013 without server access via a web browser – The default security is restrictive rather than permissive; zero authentication rules means no users have access to anything – All that is required to run PSWA is a properly-configured PowerShell Web Access gateway, and a client device browser that supports JavaScript and accepts cookies• Cons: – No profile means there is no good way to auto-load SharePoint Snap in or other scripts, functions or variables – Requires Windows Server 2012For more on PSWA, go here! (don’t worry, it’s TechNet) http://bit.ly/x18ztj 12 | SharePoint Saturday Austin 2013

14.
SURPRISE!• We’re going to try something new today…• Let’s try to do a technical demo and presentation using ONLY a browser and a PowerShell editor! 14 | SharePoint Saturday Austin 2013

15.
DEMONSTRATIONManipulating a SharePoint Site Collection using out-of-the-box PowerShellCmdlets

16.
DEMO RECAP• Used Get-SPSite to get a SharePoint Site Collection…• Stored the SPSite object into the $site variable• Created a $web variable from $site.rootweb• Used Get-Member to view Methods and Properties associated with the Web• Viewed and changed properties on the $web object using PowerShell• Used the $web variable to change the Site Title using the SP Object Model• Had some fun! 16 | SharePoint Saturday Austin 2013

17.
DEMONSTRATION TWOCreating a new PowerShell Function for reusability

18.
DEMO RECAP• Used the previous demo example to create a basic function using PowerShell ISE V3• Added and demonstrated Comment-based help and parameters• Tried it out• Had more fun! 18 | SharePoint Saturday Austin 2013

19.
EXTENDING POWERSHELL WITH SCRIPTS ANDFUNCTIONS• 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… 19 | SharePoint Saturday Austin 2013

20.
NOW, FOR THE GRAND FINALE…• You’ve seen some cool cmdlets, we’ve piped, we’ve used Get- History, Select-Object, etc…• There are a few cmdlets that can make bulk tasks VERY easy and fun… – Get-Content – ForEach-Object• Using these in conjunction with other SharePoint cmdlets or custom functions can make your PowerShell life much more awesome 20 | SharePoint Saturday Austin 2013

21.
WHAT WERE THOSE AGAIN?• Get-Content – Can read the contents of a file… – Can store the contents in a variable… – Can process XML files… – Can be piped into other cmdlets…• ForEach-Object – Provides a way to loop through - and perform an action on - each item in a collection.… 21 | SharePoint Saturday Austin 2013

23.
DEMONSTRATION THREEAutomating the provisioning of bulk sites and pages using XML input

24.
DEMO RECAP• Used the following cmdlets in an Advanced Function to automate the provisioning of 5 SharePoint Sites, each with several Publishing Pages, all from XML input: – Get-Content – ForEach-Object – New-SPWeb – Write-Progress• Used Windows PowerShell ISE V3 to edit our function by adding Parameters, eliminating hard-coded values…• Tried out our cool, new function…• Checked out the sites and pages 24 | SharePoint Saturday Austin 2013

25.
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… 25 | SharePoint Saturday Austin 2013