Tips Tricks and Random Goodness Gary Lapointe Director Aptillon Inc SharePoint MVP About Me Aptillon Inc Director and Founding Partner httpwwwaptilloncom SharePoint MVP since January 2008 ID: 739971
Download Presentation The PPT/PDF document "SharePoint 2010 & PowerShell:" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
SharePoint 2010 & PowerShell:Tips, Tricks, and Random Goodness
Gary Lapointe
Director, Aptillon, Inc.
SharePoint MVPSlide2
About MeAptillon, Inc.
Director and Founding Partner
http://www.aptillon.com
SharePoint MVP since January 2008Blog: http://blog.falchionconsulting.comTwitter: @glapointeSlide3
Load Snap-in For any EditorSlide4
Run ElevatedSlide5
Finding HelpDocumentation: help <
cmdlet
name>
Discovery:Get-CommandGet-MemberGet-VerbSlide6
PowerShell Command Builder
http://
technet.microsoft.com/en-us/sharepoint/ff603532Slide7
Know Your Output Options
Not like throwing an exception!
help
about_Preference_Variables
Exact same thingSlide8
Fancy Output
Baloon
Tips
Text to SpeechSlide9
WhatIf???Slide10
Negating Switch Statements
Bug: Enables Kerberos
Omitting will disable KerberosSlide11
Don’t Use ForEach-Object in ScriptsSlide12
Test Loops & Conditions Before Making Changes
But Wait! What’s wrong with this example?!?!Slide13
Objects Need to be Disposed!
Don’t rely on the
SPAssignmentCollection
!Slide14
Functions Can Support the Pipeline!
Be Careful! Extra Work is Needed for normal function calls!Slide15
Use Advanced Parameters
Type
help
about_functions_advanced_parameters
for more examplesSlide16
Create Dynamic Objects for Complex Output (as opposed to Select-Object)Slide17
Adaptive Type System: XMLSlide18
SplattingProvides
cmdlet
properties via a hash table
Create a hash table: $varname
= @{"key"=value;…}
Pass to
cmdlet
as
@
varname
New-
SPSite
@
varnameSlide19
Executing Script Block VariablesSlide20
Null HTTP ContextSlide21
Watch for Cached AssembliesWhen 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)Slide22
Enabling Remoting
Run
Enable-
PsRemoting on the client and server machinesMust 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
2Slide23
Remoting Session Configurations
Use
Register-
PSSessionConfiguration to preload SharePoint PowerShell Snap-InMust also set threading optionsUse
Set-
PSSessionConfiguration
with
-
ShowSecurityDescriptorUI
parameter to set security
Provide configuration name when calling
New-
PSSessionSlide24
Additional Resources
http://blog.falchionconsulting.com
Buy my book
PowerShell.comlots of good tipsPowerShell Cheat Sheet:http://tinyurl.com/3hgtfkeSlide25
About Aptillon
SharePoint MVPs
Microsoft Certified Master
Consultants, Trainers, Authors, Speakers, BloggersGreat People, Great Experience, Great Passion
Matthew McDermott
David Mann
Gary Lapointe
Darrin Bishop
Maurice Prather
Dan Holme
Todd BaginskiSlide26
Questions?