Great people, great experience, great passion Administering SharePoint with Windows PowerShell Go Beyond the Management Shell with SharePoint and Windows.

Slides:



Advertisements
Similar presentations
Week 6: Chapter 6 Agenda Automation of SQL Server tasks using: SQL Server Agent Scheduling Scripting Technologies.
Advertisements

You’ve Got a Cloud- Familiar Tools to Manage IT Bob Hunt Sr. IT Pro Evangelist
Workflow Manager Tips & Tricks. Mai Omar Desouki Workflow Manager Tips & Tricks
Module 5: Creating and Configuring Group Policy
Microsoft PowerShell Tom Roeder CS fa. Motivation.NET as a platform shell web server database access Native access to resources eaiser to manage.
CS 4800 By Brandon Andrews.  Specifications  Goals  Applications  Design Steps  Testing.
James Boother Blog: INTRODUCTION TO POWERSHELL.
Aptillon, Inc. – Director and Founding Partner – SharePoint MVP since January 2008 Blog:
10.1 © 2004 Pearson Education, Inc. Exam Planning, Implementing, and Maintaining a Microsoft Windows Server 2003 Active Directory Infrastructure.
SharePoint 2010 Administration using PowerShell Brian Caauwe Senior Consultant – SharePoint – MCTS March 20, 2010.
Guide To UNIX Using Linux Third Edition
Guide To UNIX Using Linux Third Edition
MCTS Guide to Microsoft Windows Server 2008 Network Infrastructure Configuration Chapter 7 Configuring File Services in Windows Server 2008.
11 SYSTEMS ADMINISTRATION AND TERMINAL SERVICES Chapter 12.
Adding a Module The Import-Module cmdlet  Can be used to load any external module into PowerShell.  Uses the following syntax to add the ActiveDirectory.
9.1 © 2004 Pearson Education, Inc. Exam Planning, Implementing, and Maintaining a Microsoft Windows Server 2003 Active Directory Infrastructure.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
Remote Desktop Services Remote Desktop Connection Remote Desktop Protocol Remote Assistance Remote Server Administration T0ols.
Introduction to Shell Script Programming
Ch 8. The Control Panel Window –Category View The Control Panel Window –Small icons View.
Variations and the MUI in SharePoint 2010 Gary Lapointe, MVP.
Microsoft ® Official Course Module XA Using Windows PowerShell ®
PowerShell Basics. o PowerShell is a great way to manipulate server and/or workstation components o It’s geared toward system administrators by creating.
Appendix A Starting Out with Windows PowerShell™ 2.0.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
PowerShell Shenanigans Lateral Movement with PowerShell
1 Session 3: Flow Control & Functions iNET Academy Open Source Web Programming.
Section 6: Using Windows PowerShell to Manage Group Policy Introducing Windows PowerShell Windows PowerShell Library for Group Policy Windows PowerShell-Based.
Planning a Group Policy Management and Implementation Strategy Lesson 10.
Oracle Data Integrator Procedures, Advanced Workflows.
POWERSHELL SHENANIGANS KIERAN JACOBSEN HP ENTERPRISE SERVICES.
Addison Wesley is an imprint of © 2010 Pearson Addison-Wesley. All rights reserved. Engineering Computation with MATLAB Second Edition by David M. Smith.
1 Chapter Overview Performing Configuration Tasks Setting Up Additional Features Performing Maintenance Tasks.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
What’s New in SharePoint 2010 SharePoint 2010 Development Primer New Developer Tools for SharePoint 2010 SharePoint 2010 Integration with PowerShell.
Lesson 12: Configuring Remote Management
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Corey Hynes HynesITe, Inc Session Code: SRV317 Objectives Let you walk out of here, being able to run a script against an OU of computers, to make some.
Configuring and Troubleshooting Identity and Access Solutions with Windows Server® 2008 Active Directory®
© Wiley Inc All Rights Reserved. MCSE: Windows Server 2003 Active Directory Planning, Implementation, and Maintenance Study Guide, Second Edition.
Todd Klindt and Shane Young SharePoint911. Who is this Todd guy?
Administering Microsoft Windows Server 2003 Chapter 2.
Week 4 Objectives Overview of Group Policy Group Policy Processing Implementing a Central Store for Administrative Templates.
Implementing a Group Policy Infrastructure
 It is Microsoft's new task-based command- line shell and scripting language designed especially for system administration.  It helps Information Technology.
Module 14: Advanced Topics and Troubleshooting. Microsoft ® Windows ® Small Business Server (SBS) 2008 Management Console (Advanced Mode) Managing Windows.
Application Lifecycle Management - automated builds and testing for SharePoint projects Chris O’Brien SharePoint MVP OSP432.
Introduction to SQL Server Automation with Powershell by Chris Sommer.
PHP Condtions and Loops Prepared by Dr. Maher Abuhamdeh.
Office PowerShell administration
Lesson 6: Configuring Servers for Remote Management
PowerShell 2.0 Remoting Ravikanth C.
Matlab Training Session 4: Control, Flow and Functions
TechEd /3/2018 4:18 AM © 2013 Microsoft Corporation. All rights reserved. Microsoft, Windows, and other product names are or may be registered trademarks.
Deploying and Configuring SSIS Packages
Scripts & Functions Scripts and functions are contained in .m-files
Getting Started with the Data ONTAP PowerShell Toolkit
Download dumps - Microsoft Real Exam Questions Dumps4download
Introduction to PowerShell
Windows PowerShell Remoting: Definitely NOT Just for Servers
Microsoft Ignite NZ October 2016 SKYCITY, Auckland.
Getting started with Powershell for the DBA
Manage Your Enterprise from a Single Seat: Windows PowerShell Remoting
In this session… Introduce what we’re talking about
PowerShell Best Practices for SQL DBA’s
Building your SharePoint Farm with PowerShell
Planning a Group Policy Management and Implementation Strategy
Governing Your Enterprise with Policy-Based Management
Windows Remote Management
Presentation transcript:

great people, great experience, great passion Administering SharePoint with Windows PowerShell Go Beyond the Management Shell with SharePoint and Windows PowerShell

great people, great experience, great passion Gary Lapointe Aptillon, Inc. – Director and Founding Partner – SharePoint MVP since January 2008 Blog:

great people, great experience, great passion Agenda Conditional Logic Iteration Functions and Parameters Supporting the PipeLine Scripts Error Handling Remoting

great people, great experience, great passion Load Snap-in For any Editor

great people, great experience, great passion Conditional Logic if / elseif / else if ( ) { } elseif ( ) { } else { } switch switch ( ) { { } default { } Only perform a given task when an expression evaluates to $true

great people, great experience, great passion Iteration While while ( ) { } Do While do { } while ( ) Do Until do { } until( ) For Loop for ( ; ; ) { } Foreach foreach ( in ) { } Warning!!! The foreach statement is not the same as the ForEach-Object cmdlet (aliased as foreach and %) Warning!!! The foreach statement is not the same as the ForEach-Object cmdlet (aliased as foreach and %)

great people, great experience, great passion Quick Tips Verify your conditional logic before making changes! Test your loops before making any changes within them! Watch for disposal issues when iterating through SPSite and SPWeb objects!

great people, great experience, great passion Abstract common/complex tasks into a reusable unit of code Name and call functions just like cmdlets: function Set-SPListVersioning($list, $enable) {…} Set-SPListVersioning $list $true Set-SPLIstVersioning -list $list -enable $true Functions function ( ) { [return [ ]] }

great people, great experience, great passion Function Parameters Can use either implicit or explicit parameters Implicit Example: function ($param1, $param2, $paramN) { … } Explicit Example: function () { param ( $param1, $param2 ) } Optionally prefix variable names with type information

great people, great experience, great passion Advanced Function Parameters With explicit parameters you can add cmdlet binding attributes function Set-SPListVersioning() { [CmdletBinding()] param ( [Parameter(Mandatory=$true, Position=0)], [ValidateNotNull()] [Microsoft.SharePoint.SPList]$List, [Parameter(Mandatory=$false, Position=1)] [switch]$Enable ) } Type help about_functions_advanced_parameters for more examples

great people, great experience, great passion Current object is accessible via the $_ automatic variable Supporting the PipeLine function ( ) { begin { } process { } end { } } Be Careful!! PipeLine enabled functions need extra handling when called like a normal function Be Careful!! PipeLine enabled functions need extra handling when called like a normal function

great people, great experience, great passion Quick Tips Best Practice: Include a Pipeline parameter and name it $InputObject Use the filter statement if begin {} and end {} are not needed:

great people, great experience, great passion Scripts A script is, effectively, just a function known by a file name A script can contain many different functions, but doesn’t have to have any A script can have explicit parameters, just like a function Give scripts a.ps1 file extension Load all script functions into memory using “dot source notation”

great people, great experience, great passion Quick Tips Be careful of scripts that execute when loaded – Use a function to wrap tasks Functions within scripts can be made available without dot sourcing by changing the scope of the function: function global: () { … }

great people, great experience, great passion try / catch / finally only works with V2 – Use trap statements for V1 (or just don’t use V1!) In the catch statement block, use the $_ automatic variable to access the error details The finally statement block is optional Error Handling try { } catch [error type][, [error type]] { } finally { }

great people, great experience, great passion WINDOWS POWERSHELL REMOTING Administering SharePoint remotely…

great people, great experience, great passion Remoting PowerShell Remoting uses WinRM, Microsoft’s implementation of the WS- Management protocol – WinRM allows you to run scripts against remote servers over HTTP and HTTPS Works with V2 only Requires that WinRM be enabled on both the client and the server

great people, great experience, great passion Enabling Remoting Run Enable-PsRemoting on the client and server machines Must Enable CredSSP – Credential Security Support Provider – Allows cmdlets to talk to SQL using the provided credentials (handles the double-hop issue) Increase the MaxMemoryPerShellMB setting on remote server (default is 150MB) – Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1000 Decrease MaxShellsPerUser and MaxConcurrentUsers (default is 5) – Set-Item WSMan:\localhost\shell\MaxShellsPerUser 2 – Set-Item WSMan:\localhost\shell\MaxConcurrentUsers 2

great people, great experience, great passion Enabling CredSSP On the client machine – Group Policy must be edited to allow credential delegation to the target computer. Use gpedit.msc – Computer Configuration -> Administrative Templates -> System -> Credentials Delegation -> Allow Delegating Fresh Credentials – Verify that it is enabled and configured with an SPN appropriate for the target computer (WSMAN/myserver.domain.com or WSMAN/*.domain.com) – May have to similarly enable “Allow Fresh Credentials with NTLM-only Server Authentication” if the above setting does not work – Enable-WSmanCredSSP -Role Client - DelegateComputer On the server machine – Enable-WSmanCredSSP -Role Server

great people, great experience, great passion Running Remote Commands

great people, great experience, great passion Session Configurations Use Register-PSSessionConfiguration to preload SharePoint PowerShell Snap-In – Must also set threading options Use Set-PSSessionConfiguration with - ShowSecurityDescriptorUI parameter to set security Provide configuration name when calling New- PSSession

great people, great experience, great passion DEMO… Windows PowerShell Remoting

great people, great experience, great passion Summary If you plan on writing more than 2-3 lines of PowerShell then consider using a script editor Test your scripts incrementally – Validate your loops and conditionals before making changes! Consider PowerShell remoting over integrated login for common admin tasks