Aptillon, Inc. – Director and Founding Partner – SharePoint MVP since January 2008 Blog:...

26
SharePoint 2010 & PowerShell: Tips, Tricks, and Random Goodness Gary Lapointe Director, Aptillon, Inc. SharePoint MVP
  • date post

    20-Dec-2015
  • Category

    Documents

  • view

    217
  • download

    1

Transcript of Aptillon, Inc. – Director and Founding Partner – SharePoint MVP since January 2008 Blog:...

Page 1: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

SharePoint 2010 & PowerShell:Tips, Tricks, and Random Goodness

Gary LapointeDirector, Aptillon, Inc.

SharePoint MVP

Page 2: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

About Me

• Aptillon, Inc.– Director and Founding Partner– http://www.aptillon.com

• SharePoint MVP since January 2008• Blog: http://blog.falchionconsulting.com• Twitter: @glapointe

Page 3: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Load Snap-in For any Editor

Page 4: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Run Elevated

Page 5: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Finding Help

• Documentation: help <cmdlet name>• Discovery:– Get-Command– Get-Member– Get-Verb

Page 6: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

PowerShell Command Builderhttp://technet.microsoft.com/en-us/sharepoint/ff603532

Page 7: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Know Your Output Options

Not like throwing an exception!

help about_Preference_Variables

Exact same thing

Page 8: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Fancy Output

Baloon Tips

Text to Speech

Page 9: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

WhatIf???

Page 10: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Negating Switch Statements

Bug: Enables KerberosOmitting will disable Kerberos

Page 11: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Don’t Use ForEach-Object in Scripts

Page 12: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Test Loops & Conditions Before Making Changes

But Wait! What’s wrong with this

example?!?!

Page 13: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Objects Need to be Disposed!

Don’t rely on the SPAssignmentCollection!

Page 14: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Functions Can Support the Pipeline!

Be Careful! Extra Work is Needed for

normal function calls!

Page 15: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Use Advanced Parameters

Type help about_functions_advanced_parameters for more examples

Page 16: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Create Dynamic Objects for Complex Output (as opposed to Select-Object)

Page 17: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Adaptive Type System: XML

Page 18: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Splatting• Provides cmdlet properties via a hash table• Create a hash table: – $varname = @{"key"=value;…}

• Pass to cmdlet as @varname– New-SPSite @varname

Page 19: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Executing Script Block Variables

Page 20: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Null HTTP Context

Page 21: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Watch for Cached Assemblies

• When activating Features via PowerShell, close your PowerShell session after each updated Solution deployment– Applies to any references to code that have been

updated, not just Features (but Features are the more common scenario)

Page 22: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Enabling Remoting• Run Enable-PsRemoting on the client and server machines• Must Enable CredSSP on client and server machines

– Client: Enable-WSmanCredSSP -Role Client -DelegateComputer <remote server name>

– Server: Enable-WSmanCredSSP -Role Server• Increase the MaxMemoryPerShellMB setting on server (default is

150MB)– Set-Item WSMan:\localhost\Shell\MaxMemoryPerShellMB 1024

• Decrease MaxShellsPerUser and MaxConcurrentUsers (default is 5)– Set-Item WSMan:\localhost\shell\MaxShellsPerUser 2– Set-Item WSMan:\localhost\shell\MaxConcurrentUsers 2

Page 23: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Remoting 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

Page 24: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Additional Resources

• http://blog.falchionconsulting.com– Buy my book

• PowerShell.com– lots of good tips

• PowerShell Cheat Sheet:– http://tinyurl.com/3hgtfke

Page 25: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

About Aptillon• SharePoint MVPs• Microsoft Certified Master• Consultants, Trainers, Authors, Speakers,

Bloggers• Great People, Great Experience, Great Passion

Matthew McDermottDavid Mann Gary Lapointe Darrin Bishop Maurice Prather Dan HolmeTodd Baginski

Page 26: Aptillon, Inc. – Director and Founding Partner –  SharePoint MVP since January 2008 Blog: ://blog.falchionconsulting.com.

Questions?