PowerShell For SharePoint Developers Neil Iversen Inetium

Slides:



Advertisements
Similar presentations
Introduction to Unix – CS 21 Lecture 11. Lecture Overview Shell Programming Variable Discussion Command line parameters Arithmetic Discussion Control.
Advertisements

$$ Idea Updatable help system Method overload discovery HelpUri attribute support HelpFile property on FunctionInfo Simplified Where and.
Microsoft PowerShell Tom Roeder CS fa. Motivation.NET as a platform shell web server database access Native access to resources eaiser to manage.
Packaging Your Advanced SharePoint Customizations Neil Iversen Inetium
Find Command Characteristics –Locate files descending from multiple starting points –Employs regular expressions Examples On entire system: >find / -name.
James Boother Blog: INTRODUCTION TO POWERSHELL.
CS Lecture 03 Outline Sed and awk from previous lecture Writing simple bash script Assignment 1 discussion 1CS 311 Operating SystemsLecture 03.
Neil Iversen Inetium justaddcode.com. The Plan  PowerShell Sales Pitch  Creating Scripts  Type Extensions  Rolling your own Cmdlets  Other Extensionibility.
CS-502 Fall 2006Project 1, Fork1 Programming Project 1 – Fork.
Great people, great experience, great passion Administering SharePoint with Windows PowerShell Go Beyond the Management Shell with SharePoint and Windows.
Neil Iversen Inetium
SharePoint 2010 Administration using PowerShell Brian Caauwe Senior Consultant – SharePoint – MCTS March 20, 2010.
INTRODUCTION TO POWERSHELL Neil Iversen. Points of Interest  Introduction  Getting Around  Basic Syntax  Making yourself at ~  Not-So-Basic Syntax.
Guide To UNIX Using Linux Third Edition
Introduction to Unix (CA263) Introduction to Shell Script Programming By Tariq Ibn Aziz.
POWERSHELL Dr. Sarah Gothard CEG 233 Spring 2010.
7/17/2009 rwjBROOKDALE COMMUNITY COLLEGE1 Unix Comp-145 C HAPTER 2.
Introduction to SharePoint Development with VS2010 Paul Yuknewicz Lead Program Manager
© 2007 Asynchrony Solutions, Inc. 1 10/29/07 Introduction to PowerShell Brian Button VP Engineering Asynchrony Solutions, Inc
MS WINDOWS POWER SHELL CSE 535 Operating Systems.
Introduction to Shell Script Programming
Windows PowerShell Deep Dive 1 Morgan Simonsen Ementor.
PowerShell Basics. o PowerShell is a great way to manipulate server and/or workstation components o It’s geared toward system administrators by creating.
Python: An Introduction
Computer Programming for Biologists Oct 30 th – Dec 11 th, 2014 Karsten Hokamp  Fill out.
Dynamic Languages and the Web Jimmy Schementi Microsoft
Module 3 Administering and Automating SharePoint.
Section 6: Using Windows PowerShell to Manage Group Policy Introducing Windows PowerShell Windows PowerShell Library for Group Policy Windows PowerShell-Based.
CPSC 217 T03 Week I Part #1: Unix and HELLO WORLD Hubert (Sathaporn) Hu.
Writing Shell Scripts ─ part 3 CSE 2031 Fall October 2015.
Course materials may not be reproduced in whole or in part without the prior written permission of IBM. 5.1 © Copyright IBM Corporation 2008 Unit 11: Shell.
UNIX Commands. Why UNIX Commands Are Noninteractive Command may take input from the output of another command (filters). May be scheduled to run at specific.
Introduction to Windows PowerShell DANIEL HIBBERT PRIMER FIELD ENGINEER DMVMUG User Conference 2013 – Reston, VA.
CN1266 Network Scripting V1.2 Kemtis Kunanuraksapong MSIS with Distinction MCTS, MCDST, MCP, A+
PowerShell for SharePoint Developers and Administrators Michael Blumenthal Magenic Technologies
L&T Infotech1 UNIX – Getting Started - Aneesh Ramani.
Cherwell + PowerShell = Powerful Workflow Automation
What’s New in SharePoint 2010 SharePoint 2010 Development Primer New Developer Tools for SharePoint 2010 SharePoint 2010 Integration with PowerShell.
CS252: Systems Programming Ninghui Li Slides by Prof. Gustavo Rodriguez-Rivera Topic 7: Unix Tools and Shell Scripts.
Windows PowerShell Introduction 1 Morgan Simonsen Ementor.
 An alias is an alternative name assigned to a Cmdlet.  Aliases allow users to quickly interact with the shell.  The Cmdlet get-alias is.
Todd Klindt and Shane Young SharePoint911. Who is this Todd guy?
POWERSHELL BASICS. BACKGROUND  Powershell is a task automation and scripting language based off the.NET framework  It provides the user full access.
Advanced Feature Development Neil Iversen Inetium
 It is Microsoft's new task-based command- line shell and scripting language designed especially for system administration.  It helps Information Technology.
Windows PowerShell. What is Windows PowerShell? A command-line interface (CLI) A new way of developing Windows and other products to be more manageable.
Sed. Class Issues vSphere Issues – root only until lab 3.
Automating SharePoint 2010 administration tasks with Power Shell Toni Frankola SharePoint MVP, Croatia
Linux A practical introduction. 1)Background and Getting Started Linux is an operating system with multiple providers Red Hat/CentOS (our version) Ubuntu.
EMT 2390L Lecture 3 Dr. Reyes Reference: The Linux Command Line, W.E. Shotts.
Introduction to SQL Server Automation with Powershell by Chris Sommer.
Ravikanth C.
Start-SPPowerShell – Introduction to PowerShell for SharePoint Admins and Developers Paul BAker.
Building Powerful Workflow Automation with Cherwell and PowerShell
Andy Wang Object Oriented Programming in C++ COP 3330
Agenda Bash Shell Scripting – Part II Logic statements Loop statements
Introduction to PowerShell
PYTHON: AN INTRODUCTION
Introduction to PowerShell
SharePoint Saturday Omaha April 2016
CS-3013 & CS-502 Operating Systems Summer 2006
Making PowerShell Useful
Customizing the SharePoint Mobile Experience
PowerShell Best Practices for SQL DBA’s
Making PowerShell Useful
Andy Wang Object Oriented Programming in C++ COP 3330
Cmdlets “Command-lets”
CSC 352– Unix Programming, Fall 2012
Bash Scripting CS 580U - Fall 2018.
Presentation transcript:

PowerShell For SharePoint Developers Neil Iversen Inetium

The Plan PowerShell ● Introduction ● Basic Syntax ● Not-So-Basic Syntax SharePoint ● Using the SharePoint Object Model ● Debugging Code using PowerShell ● Showing Off ● SharePoint Specific? (Providers,…) Questions

Why PowerShell for Developers? Better visibility into the Object Model ● Find all the instances of a content type in a Site Automated or repetitive tasks ● Add a web part to a page on 500 sites Faster Development Cycle

Developing Faster Traditional SharePoint Development ● Time wasted during Testing PowerShell /.NET Hybrid Development ● ‘Risky’ development done in PoSH ● Code converted to.NET (C#/VB) ● Shorter Deploy/Test Cycle CodeCompileDeployTest Prototype (PoSH) CodeCompileDeployTest CodeCompileDeploy

What is PowerShell? Different things to different people It’s a ● Shell ● Cool.bat file ● VBScript replacement ● Admin’s Best Friend ● Developer’s Best Friend ● …

cmd.exe

+

unix cmdline

+

.net

=

An ugly by powerfull shell

Getting Around dir cd del Mkdir help  ls  cd  rm  mkdir  man

Core Components Alias ● cd = set-location ● Dir = get-childitem Cmdlet ● Workhorse of PowerShell Function ● Block of script Provider ● Adds alternate ‘directory structure’ ● Think ‘/proc’ only niftier ● Get-PSdrive Snapin ● Group of PowerShell functionality

DEMO: Getting Around

Conditions and Flow Control Variables ● $foo = “bar” #implicitly typed as System.String ● $ary = 4,2,5,2 #typed as object[] ● [xml]$xdoc = “ b1 b2 ” Some Operators ● -eq ● -lt / -gt ● -le / -ge ● -like / -notlike ● -match / -imatch Control ● If ● switch help about_comparison_operators

The Pipeline Everything is a System.Object ● Unless its something more useful dir | where-object {$_.Length –gt 5} | select-object –last 2 | sort-object -prop Extension –desc $anArray | sort

Most Useful Commands Foreach-object ● dir | foreach-object { $_.Name } ● Alias: dir | % { $_.Name } Where-object ● dir | where-object {$_.Length –gt 10} ● Alias: dir | ? {$_.Length –gt 10} Select-object ● dir | select-object –first 5 ● Alias: none Honorable Mentions: Sort-Object, Group-Object

DEMO: Exploring the Pipeline

LINQish PowerShell Syntax LINQPowerShell int[] numbers = { 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 }; var lowNums = from n in numbers where n < 5 select n; Console.WriteLine("Numbers < 5:"); foreach (var x in lowNums) { Console.WriteLine(x); } $numbers = 5, 4, 1, 3, 9, 8, 6, 7, 2, 0 Write-host “Numbers < 5:” $numbers | ?{$_ -lt 5}

Isn’t this for SharePoint Developers? SharePoint has a rich.NET Object Model PowerShell interacts natively with.NET SharePoint’s internal values are hidden ● Lots of functionality not accessible via the UI ● Validation of custom code Debugging is Difficult ● Especially on a remote machine ● Code/Compile/Deploy/Test/Repeat Cycle

Loading the Object Model [System.Reflection.Assembly]::LoadWithPartialN ame(“Microsoft.SharePoint”) $site = new-object Microsoft.SharePoint.SPSite( $web = $site.OpenWeb() $web.Title

Some Useful Commands Display all the Lists ● $web.Lists Display Properties Sorted by Name ● $item.Properties | sort –prop Name Set an item’s properties ● $item.Properties[“SomeKey”] = “value” ● $item.Properties.Update()

DEMO: Working with Item Properties

Exploring SharePoint Development Not Everything is Intuitive ● Object Model Gives Hints Compile->Deploy->Test Loop is Long ● Makes failed attempts expensive Using PowerShell Lowers (some) Pain ● No Compile/Deploy Loop ● Get Immediate Feedback

DEMO: SPListItems and Folders

Extending Types Command Line version of Mashups Add Properties and Methods to ANY type Simplifies potentially tedious commands On The Fly Magic ● Add-Member The (SemiPermanent) Magic ● Ps1xml ● Update-type –pre/postpend my.ps1xml

DEMO: Extending Types

Taking it Further PowerShell Community Extensions (PSX) ● SharePoint Provider (v2 only) ● PowerTab ● ab.aspx ab.aspx

Your Feedback is Important Please fill out a session evaluation form and either put them in the basket near the exit or drop them off at the conference registration desk. Thank you!

Questions?

Thanks! Neil Iversen Inetium