PowerShell for SharePoint or Administrators Can Use the Object Model, Too 30 th October 2008 Sergey Zelenov Premier Field Engineer Microsoft Corporation.

Slides:



Advertisements
Similar presentations
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Advertisements

© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Preface Demo A Quick Thank You How Did We Do It?
Feature: Identity Management - Login © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Windows 7 Training. Windows ® 7 Compatibility Session 0 Isolation Isolation of Windows 7 Services.
Feature: Microsoft Dynamics GP 2013 R2 Dashboards © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
© 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
* Archiving provided by Exchange.
Feature: Reprint Outstanding Transactions Report © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
Feature: Purchase Requisitions - Requester © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
MIX 09 4/15/ :14 PM © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
demo Default WANGPSLookup Default WANGPS.
Feature: Payroll and HR Enhancements © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Co- location Mass Market Managed Hosting ISV Hosting.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Windows 7 Training Microsoft Confidential. Windows ® 7 Compatibility Version Checking.
Multitenant Model Request/Response General Model.
Feature: Purchase Order Prepayments II © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Announcing Demo Announcing.
Feature: OLE Notes Migration Utility
Feature: Web Client Keyboard Shortcuts © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Feature: SmartList Usability Enhancements © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Session 1.
Built by Developers for Developers…. © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
 Rico Mariani Architect Microsoft Corporation.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Assign an Item to Multiple Sites © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
WinHEC /22/2017 © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Print Remaining Documents © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
Connect with life Connect with life
demo Receive Inventory Export Parse and Normalize.
© 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or.
Feature: Document Attachment –Replace OLE Notes © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
North America Region Europe Region Asia Pacific Region.
Feature: Suggested Item Enhancements – Sales Script and Additional Information © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows.
Feature: Customer Combiner and Modifier © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
Feature: Employee Self Service Timecard Entry © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
Ian Ellison-Taylor General Manager Microsoft Corporation PC27.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.
demo Instance AInstance B Read “7” Write “8”

customer.
demo © 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names.
demo Demo.
Feature: Void Historical/Open Transaction Updates © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
demo QueryForeign KeyInstance /sm:body()/x:Order/x:Delivery/y:TrackingId1Z
Feature: Suggested Item Enhancements – Analysis and Assignment © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and.
projekt202 © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are.
The CLR CoreCLRCoreCLR © 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product.
© 2009 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks.
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or.

IoCompleteRequest (Irp);... p = NULL; …f(p);
Возможности Excel 2010, о которых следует знать
Renewed Developer Dashboard
Title of Presentation 11/22/2018 3:34 PM
Title of Presentation 12/2/2018 3:48 PM
8/04/2019 9:13 PM © 2006 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered.
Виктор Хаджийски Катедра “Металургия на желязото и металолеене”
PENSACOLA ENERGY WORK PLAN OCTOBER 10, 2016
Title of Presentation 5/12/ :53 PM
Шитманов Дархан Қаражанұлы Тарих пәнінің
Title of Presentation 5/24/2019 1:26 PM
5/24/2019 6:44 PM 1/8/18 Bell #10 In a world governed by the gods, is there any room for human will? Do human choices make a difference? EXPLAIN © 2007.
日本初公開!? Vista の新機能を実演 とっちゃん わんくま同盟 7/23/2019 9:09 AM
Title of Presentation 7/24/2019 8:53 PM
Presentation transcript:

PowerShell for SharePoint or Administrators Can Use the Object Model, Too 30 th October 2008 Sergey Zelenov Premier Field Engineer Microsoft Corporation

Agenda What is PowerShell anyway? History Ground principles Availability Future PowerShell and SharePoint Setting the scene... Using PowerShell’s parsing might Harnessing SharePoint Object Model

What is PowerShell anyway? History Idea based on a study commissioned by Microsoft in the early 2000s Inspired by Microsoft’s moving into the server marketplace Originally based on POSIX shell as specified in IEEE Influenced by Perl and UNIX shells Written in.NET providing direct access to the power of the framework Current version is 1.0, 2.0 is coming soon!

Shell or Scripting Language? Best of both worlds!! ShellScripting Language AliasesModules Wildcard matchingDebugging Starting other programsScript-Optimized Command history Command completion What is PowerShell anyway? Ground Principles

What is PowerShell anyway? Ground Principles Cmdlets -Use verb-noun pairs Get-Command Add-Content Copy-Item Read-Host Set-Date -Return objects  Implemented by a.NET class that derives from the Cmdlet base class Objects -Everything is an object -Uses and extends.NET type system -Adapts objects through the PSObject layer -Native support for accessing.NET and COM classes

Pipelines -Series of commands separated by the pipe operator “|” get-wmiobject win32_logicaldisk | sort -desc freespace | select -first 3 | format-table -autosize deviceid, freespace -Pass output objects from one command to the next -Support streaming (in-process!) What is PowerShell anyway? Ground Principles

What is PowerShell anyway? Availability Available as a separate download (in fact a Windows Update) for: -Microsoft Windows XP Service Pack 2 (x86 and x64) -Microsoft Windows Vista (x86 and x64) -Windows Server 2003 (all editions, x86 and x64) Included in Windows Server 2008 as a Feature -Not installed by default but can be added at any time

What is PowerShell anyway? Future Exchange Management Shell is already based on Windows PowerShell All Microsoft server products are eventually to become PowerShell- compatible PowerShell a weapon of choice for next version of SharePoint – STSADM included for backward compatibility only!

DEMO: PowerShell First Steps Sergey Zelenov Premier Field Engineer Microsoft Corporation

Setting the Scene Prepare the environment for working with SharePoint Taking care of security -Execution policy is set to Restricted by default -Consider changing policy to RemoteSigned or Unrestricted to allow scripts to run Loading SharePoint assemblies -Use static methods of the System.Reflection.Assembly class  LoadWithPartialName is obsolete but great for interactive sessions  Load must be used in scripts

Setting the Scene Loading SharePoint Assemblies [System.Reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”) [System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version= , Culture=Neutral, PublicKeyToken=71e9bce111e9429c”)

Setting the Scene Loading SharePoint Assemblies Windows SharePoint Services (WSS) Object Model -Microsoft.SharePoint -Microsoft.SharePoint.Security Microsoft Office SharePoint Server (MOSS) Object Model -Microsoft.Office.Server -Microsoft.Office.Server.Search -Microsoft.SharePoint.Portal -Microsoft.SharePoint.Publishing

Using PowerShell’s Parsing Might Parsing STSADM output -PowerShell supports XML documents as a primitive data type ([xml]) -Cast the output of an STSADM command to [xml] to use object notation $sites = [xml](Stsadm –o enumsites –url Parsing log files  Select-String cmdlet can be used for finding specific strings in ULS and IIS logs Select-String “Timer” $splogs\* *\.log

DEMO: Parsing with PowerShell Sergey Zelenov Premier Field Engineer Microsoft Corporation

Harnessing SharePoint Object Model Working with objects Static classes don’t need to be instantiated SPFarm SPUtility SPEncode “::” operator is used to retrieve static members $farm = [Microsoft.SharePoint.Administration.SPFarm]::Local New-Object cmdlet New-Object [-typeName] [[-argumentList] ] [ ] Dynamic members are retrieved using ‘common’ “.” operator $farm.Servers $farm.Services $farm.Solutions

Harnessing SharePoint Object Model Power of Reflection.NET classes are self-describing Obtain maximum information about an object without explicitly specifying members $bindflag = $([System.Reflection.BindingFlags]::Instance, [System.Reflection.BindingFlags]::Public) $props = $object.GetType().GetProperties($bindflag) foreach($propinfo in $props) { “{0}: {1}” –f $propinfo.Name, $propinfo.GetValue($object, $null) }

Harnessing SharePoint Object Model Is it all this good? SPContentDatabase class is not CLR-compliant  Solution? Use reflection! $props = [Microsoft.SharePoint.Administration.SPContentDatabase].GetPr operties($bindflag); $props | % {"{0}: {1}" -f $_.Name, $_.GetValue($site.ContentDatabase,$null)}

DEMO: PowerShell and SharePoint Object Model Sergey Zelenov Premier Field Engineer Microsoft Corporation

Resources PowerShell home page Windows PowerShell Scripts in the TechNet Scripting Center PowerShell Pack for SharePoint PowerGUI CodePlex Zach Rosenfield’s Blog From The Field blog

© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.