HDEV16: SharePoint 2010 PowerShell for Developers. Gary Lapointe, MVP Falchion Consulting, LLC gary@falchionconsulting.com



Similar documents
Using Windows PowerShell to Manage SharePoint 2010

POWERSHELL (& SHAREPOINT) This ain t your momma s command line!

Hands-On Lab. Lab 01: Getting Started with SharePoint Lab version: Last updated: 2/23/2011

EMC SourceOne for Microsoft SharePoint Storage Management Version 7.1

Troubleshooting Jive for SharePoint

SharePoint MVP Independent Consultant and Owner of Falchion Consulting, LLC.

DottsConnected SHAREPOINT 2010 ADMIN TRAINING. Exercise 1: Create Dedicated Service Accounts in Active Directory

Specops Command. Installation Guide

Item Audit Log 2.0 User Guide

Microsoft Windows PowerShell v2 For Administrators

Getting Started with the Ed-Fi ODS and Ed-Fi ODS API

Cascaded Lookup 5.0 User Guide

The full setup includes the server itself, the server control panel, Firebird Database Server, and three sample applications with source code.

SharePoint Password Change & Expiration 3.0 User Guide

HarePoint Analytics. For SharePoint. Administrator Guide

HOWTO: Installation of Microsoft Office SharePoint Server 2007

SPHOL205: Introduction to Backup & Restore in SharePoint Hands-On Lab. Lab Manual

Automating. Administration. Microsoft SharePoint with Windows. PowerShell 2.0. Gary Lapointe Shannon Bray. Wiley Publishing, Inc.

Glyma Deployment Instructions

How to Create a Delegated Administrator User Role / To create a Delegated Administrator user role Page 1

Learn how to create web enabled (browser) forms in InfoPath 2013 and publish them in SharePoint InfoPath 2013 Web Enabled (Browser) forms

COPYRIGHTED MATERIAL INDEX. Symbols

SSRS Reporting Using Report Builder 3.0. By Laura Rogers Senior SharePoint Consultant Rackspace Hosting

This module explains the Microsoft Dynamics NAV architecture and its core components.

EMC Documentum Connector for Microsoft SharePoint

Microsoft Project Server Integration with SharePoint 2010

Deploying Microsoft Operations Manager with the BIG-IP system and icontrol

SUNGARD SUMMIT 2007 sungardsummit.com 1. Microsoft PowerShell. Presented by: Jeff Modzel. March 22, 2007 Course ID 453. A Community of Learning

Developing Microsoft SharePoint Server 2013 Advanced Solutions. Version: Demo. Page <<1/8>>

Microsoft Office Web Apps Server 2013 Integration with SharePoint 2013 Setting up Load Balanced Office Web Apps Farm with SSL (HTTPS)

WolfTech Active Directory: PowerShell

Powershell Management for Defender

Installation Guide. Genesis Edition for SharePoint AgilePoint BPMS v5.0 R2 SP1 Genesis for SharePoint 2010

SETUP SSL IN SHAREPOINT 2013 (USING SELF-SIGNED CERTIFICATE)

Microsoft Corporation. Project Server 2010 Installation Guide

Windows PowerShell Fundamentals

Lab Answer Key for Module 1: Installing and Configuring Windows Server Table of Contents Lab 1: Configuring Windows Server

Microsoft SharePoint Technologies Solution Architecture

SharePoint Password Reset 1.0 User Guide

SharePoint 2016 [PREVIEW] Site Template ID List

Nintex Forms 2013 Help

Installation Guide. . All right reserved. For more information about Specops Inventory and other Specops products, visit

Configuring Cross Farm (Federated) Services in Microsoft SharePoint 2013

Acknowledgments Finding Your Way Around Windows PowerShell p. 1 Getting Started with Windows PowerShell p. 3 Installing Windows PowerShell p.

GeBro-BACKUP. Die Online-Datensicherung. MANUAL SHAREPOINT

SharePoint 2013 Syllabus

To install Multifront you need to have familiarity with Internet Information Services (IIS), Microsoft.NET Framework and SQL Server 2008.

R i o L i n x s u p p o r r i o l i n x. c o m 1 / 3 0 /

SharePoint 2010

Microsoft Enterprise Search for IT Professionals Course 10802A; 3 Days, Instructor-led

Administration Guide. . All right reserved. For more information about Specops Gpupdate and other Specops products, visit

SharePoint 2010/2013 Course

ElearningForce COPY SHAREPOINT LMS PRODUCT SUITE INSTALLATION CHECKLIST. Version: 1.0

SPHOL207: Database Snapshots with SharePoint 2013

Configuring and Administrating Microsoft SharePoint 2010 (10174) HK913S

MICROSOFT EXAM QUESTIONS & ANSWERS

Upgrades and the Cloud

Authoring for System Center 2012 Operations Manager

Click Studios. Passwordstate. Password Discovery, Reset and Validation. Requirements

Microsoft. Jump Start. M3: Managing Windows Server 2012 by Using Windows PowerShell 3.0

Web Sites, Virtual Machines, Service Management Portal and Service Management API Beta Installation Guide

"Charting the Course to Your Success!" MOC B Configuring and Administering Microsoft SharePoint Course Summary

SQL and PL/SQL Development and Leveraging Oracle Multitenant in Visual Studio. Christian Shay Product Manager, NET Technologies Oracle

Windows PowerShell. 3.0 Step by Step. Ed Wilson

Getting started with 2c8 plugin for Microsoft Sharepoint Server 2010

A SharePoint Developer Introduction

PowerShell for Exchange Admins

Forefront Management Shell PowerShell Management of Forefront Server Products

Braindumps.C questions

Nintex Workflow 2010 Installation Guide. Installation Guide Nintex USA LLC, All rights reserved. Errors and omissions excepted.

MICROSOFT BITLOCKER ADMINISTRATION AND MONITORING (MBAM)

AppDev OnDemand Cloud Computing Learning Library

Secure Messaging Server Console... 2

Windows PowerShell Cookbook

Anti-Executable Dashboard. Last modified: August 2012

TECHNICAL DOCUMENTATION SPECOPS DEPLOY / APP 4.7 DOCUMENTATION

ITMC 2079 MCTS Configuring and Administering Microsoft SharePoint 2010

Dotnet Agent Installation with Remote Management - Powershell Extension Advanced Options

How to move a SharePoint Server bit environment to a 64-bit environment on Windows Server 2008.

Know the Unknown When Developing in SharePoint 2010

SharePoint 2010 Dev Vs. Microsoft Quest Software

Using Application Insights to Monitor your Applications

PASS4TEST 専 門 IT 認 証 試 験 問 題 集 提 供 者

MarkLogic Server. Connector for SharePoint Administrator s Guide. MarkLogic 8 February, 2015

Exercise Safe Commands and Audit Trail

How to Scale out SharePoint Server 2007 from a single server farm to a 3 server farm with Microsoft Network Load Balancing on the Web servers.

Unidesk 3.0 Script to Increase UEP Size for Persistent Desktops

Using Management Shell Reports and Tracking User Access in the NetVanta UC Server

Umbraco Courier 2.0. Installation guide. Per Ploug Hansen 5/24/2011

2933A: Developing Business Process and Integration Solutions Using Microsoft BizTalk Server 2006

Transcription:

HDEV16: SharePoint 2010 PowerShell for Developers Gary Lapointe, MVP Falchion Consulting, LLC gary@falchionconsulting.com

About Me SharePoint MVP Independent Consultant and Owner of Falchion Consulting, LLC http://www.falchionconsulting.com Principal Consultant - Aptillon, Inc. http://www.aptillon.com Blog: http://stsadm.blogspot.com/ Twitter: @glapointe Email: gary@falchionconsulting.com

Agenda SharePoint 2010 PowerShell Overview Developer Cmdlets Using PowerShell with Visual Studio Developing Custom Cmdlets

Review SharePoint Specific PowerShell Concepts POWERSHELL & SHAREPOINT

STSADM/PSConfig??? They re still there but the use of them has been, for the most part, made obsolete Most everything you can do with them can be done with PowerShell (and faster) You can access them via the PowerShell console (but why would you?) Extensions to STSADM are still supported (just recompile and fix any necessary bugs related to API changes)

Popular Editors SharePoint 2010 Management Shell PowerShell Console Windows PowerShell ISE Debugging Tab Completion Syntax Highlighting PowerGUI Debugging Tab Completion Syntax Highlighting Intellisense Visual Studio Not so much may as well just use notepad

Load Snap-in For any Editor Loading the SharePoint snap-in via your profile script allows you to use any editor Run the following to create a profile script if one doesn t exist and edit it in the ISE: if (!(test-path $profile.allusersallhosts)) { new-item -type file -path $profile.allusersallhosts -force} powershell_ise $profile.allusersallhosts Add the following code to the script file and save your changes: $ver = $host select version if ($ver.version.major -gt 1) { $host.runspace.threadoptions = "ReuseThread"} if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" ` -ErrorAction SilentlyContinue) -eq $null) { Add-PSSnapin "Microsoft.SharePoint.PowerShell" }

Required Permissions Member of WSS_ADMIN_WPG and SharePoint_Shell_Access WSS_ADMIN_WPG is a local security group on the machine the user is executing commands on SharePoint_Shell_Access is a SQL Role in the target Database(s) Use Add-SPShellAdmin to add a user to these groups Add-SPShellAdmin -UserName domain\user Get-SPDatabase where {$_.Name -like "SharePoint_Content_*"} Add-SPShellAdmin -UserName domain\user Some commands (such as setup commands) require the user to be a local server admin but most do not.

PipeBind Objects Allows different representations of an artifact to be passed into cmdlets Example: SPSitePipeBind accepts either a GUID, URL, or SPSite object Get-SPWeb [-Identity <SPWebPipeBind>] [- AssignmentCollection <SPAssignmentCollection>] [- Confirm [<SwitchParameter>]] [-Filter <ScriptBlock>] [- Limit <String>] [-Regex <SwitchParameter>] [-Site <SPSitePipeBind>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>] $site = Get-SPSite "http://portal" $webs = $site Get-SPWeb $webs = $site.id Get-SPWeb $webs = "http://portal" Get-SPWeb

Handling Disposable Items SPAssignmentCollection Collection object that all SharePoint cmdlets can accept to store objects that must be disposed Get-SPSite [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Filter <ScriptBlock>] [-Limit <String>] [-WebApplication <SPWebApplicationPipeBind>] [-WhatIf [<SwitchParameter>]] [<CommonParameters>]

Assignment Collections Start-SPAssignment Start-SPAssignment [-AssignmentCollection <SPAssignmentCollection>] [-Global <SwitchParameter>] [<CommonParameters>] Stop-SPAssignment Stop-SPAssignment [-SemiGlobal <SPAssignmentCollection>] [- AssignmentCollection <SPAssignmentCollection>] [-Global <SwitchParameter>] [<CommonParameters>] Three levels of assignment: No assignment (dispose immediately) Simple assignment (use a global store) Advanced assignment (use a named store) Only Get-SPSite, Get-SPWeb, New-SPSite, and New-SPWeb use this disposal capability

Assignment Collection Example -Global stores items within an internal static variable -SemiGlobal is used for named variables and can be passed via the pipeline

Using SharePoint Cmdlets DEMO

Developer Dashboard and Solution Deployment DEVELOPER CMDLETS

Developer Dashboard The developer dashboard enables you to view performance and debugging data for a given page request. $dash = [Microsoft.SharePoint.Administration.SPWebService]:: ContentService.DeveloperDashboardSettings $dash.displaylevel = "OnDemand" $dash.traceenabled = $true $dash.update()

Solution Deployment Cmdlets Get-SPSolution Add-SPSolution stsadm -o addsolution Install-SPSolution stsadm -o deploysolution Uninstall-SPSolution stsadm -o retractsolution Remove-SPSolution stsadm -o deletesolution Update-SPSolution stsadm -o upgradesolution Get-SPFeature Enable-SPFeature stsadm -o activatefeature Disable-SPFeature stsadm -o deactivatefeature Install-SPFeature stsadm -o installfeature Uninstall-SPFeature stsadm -o uninstallfeature *There are also existing User Solution cmdlets

Solution Deployment DEMO

Executing Scripts at Build USING POWERSHELL WITH VISUAL STUDIO 2010

PowerShell Script Deployment Step Developed by Waldek Mastykarz Integrated into CKS:DEV http://cksdev.codeplex.com/

Pre/Post Build Events May need to call the SysNative version of PowerShell (x86 vs. x64 issues) C:\windows\sysnative\WindowsPowerShell\v1.0\powe rshell.exe Example from my cmdlets powershell.exe -command [System.Reflection.Assembly]::LoadFile('$(TargetPat h)');[$(projectname).mamlgenerator.cmdlethelpgen erator]::generatehelp('$(projectdir)powershell\h elp', $true)

Visual Studio 2010 Cmdlet Development BUILDING CUSTOM CMDLETS

Creating a new VS2010 Project

Key Components Required XML registration file defines the custom cmdlets and maps the name to the class and help file 14\Config\PowerShell\Registration\<project name>.xml Optional XML help file 14\Config\PowerShell\Help\<dll name>-help.xml Optional XML format file 14\Config\PowerShell\Format\<project name>.format.ps1xml Optional XML types file allows aliased properties to be declaratively added to existing types 14\Config\PowerShell\Types\<project name>.ps1xml

Registration XML

Add Required Assemblies Add the following assembly references: Microsoft.SharePoint.Po wershell System.Management.Au tomation VS2010 does not show these assemblies in the references dialog so you must either browse to them or manually edit the project file

Cmdlet Base Classes SPCmdlet SPRemoveCmdletBase SPSetCmdletBase SPGetCmdletBase SPNewCmdletBase

Creating Custom Cmdlets DEMO

Your Feedback is Important Please fill out a session evaluation form drop it off at the conference registration desk. Thank you!