share point power shell tips tricks and random goodness

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

Upload: alejandro-fuentes

Post on 06-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 1/26

SharePoint 2010 & PowerShell:

Tips, Tricks, and Random Goodness

Gary Lapointe

Director

, Aptillon, Inc.

SharePoint MVP

Page 2: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 2/26

About Me

• Aptill

on, Inc.

 – Director and Founding Partner

 –

http://www.aptillon.com• SharePoint MVP since January 2008

• Blog: http://blog.falchionconsulting.com 

• Twitter: @glapointe

Page 3: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 3/26

Load Snap

-

in For any Editor

Page 4: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 4/26

Run Elevated

Page 5: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 5/26

Finding Help

• Documentation: help <cmdlet name>

• Discovery:

 –Get-Command

 – Get-Member

 – Get-Verb

Page 6: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 6/26

PowerShell Command Builder

http://technet.microsoft.com/en-us/sharepoint/ff603532 

Page 7: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 7/26

Know Your Output Options

Not like throwing an exception!

help about_Preference_Variables

Exact same thing

Page 8: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 8/26

Fancy Output

Baloon Tips

Text to Speech

Page 9: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 9/26

WhatIf ???

Page 10: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 10/26

Negating Switch Statements

Bug: Enables Kerberos

Omitting will disable Kerberos

Page 11: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 11/26

Don’t Use ForEach-Object in Scripts

Page 12: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 12/26

Test Loops & Conditions Before

Making Changes

But Wait! What’swrong with this

example?!?!

Page 13: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 13/26

Objects Need to be Disposed!

Don’t rely on the

SPAssignmentCollection!

Page 14: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 14/26

Functions Can Support the Pipeline!

Be Careful! Extra

Work is Needed for

normal functioncalls!

Page 15: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 15/26

Use Advanced Parameters

Type help about_functions_advanced_parameters for more examples 

Page 16: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 16/26

Create Dynamic Objects for Complex Output (as

opposed to Select-Object)

Page 17: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 17/26

Adaptive Type System: XML

Page 18: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 18/26

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: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 19/26

Executing Script Block Variables

Page 20: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 20/26

Null HTTP Context

Page 21: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 21/26

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: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 22/26

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 is150MB) – Set-ItemWSMan:\localhost\Shell\MaxMemoryPerShellMB 1024

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

 – Set-ItemWSMan:\localhost\shell\MaxConcurrentUsers 2

Page 23: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 23/26

Remoting Session Configurations

• Use Register-PSSessionConfiguration to preloadSharePoint PowerShell Snap-In

 – Must also set threading options

• Use Set-PSSessionConfiguration with -ShowSecurityDescriptorUI 

parameter to set security• Provide configuration name when callingNew-PSSession

Page 24: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 24/26

Additional Resources

• http://blog.falchionconsulting.com 

 – Buy my book 

PowerShell.com – lots of good tips

• PowerShell Cheat Sheet:

 –

http://tinyurl.com/3hgtfke

Page 25: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 25/26

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: Share Point Power Shell Tips Tricks and Random Goodness

8/2/2019 Share Point Power Shell Tips Tricks and Random Goodness

http://slidepdf.com/reader/full/share-point-power-shell-tips-tricks-and-random-goodness 26/26

Questions?