POWERSHELL
(& SHAREPOINT)
12+ years as IT Professional (“IT PRO – duck – DEV “)
• A little IT PRO, little more DEV and a lot of ducking.
Certifiable in SharePoint and .NET development JAMYE FEW
SENIOR CONSULTANT
» Summit 7 Systems was chosen by KMWorld Magazine as one of the top 100 Companies that Matter in Knowledge Management along with companies such as Microsoft, Oracle and IBM.
» Summit 7 Systems was named to the 2011 and 2012 CRN Next-Gen 250 List as a company bringing innovative processes, methodologies and models to the solution provider industry.
» Top 1% of Microsoft Partners Worldwide
» Summit 7 Systems was named #6 on the 2012 CRN Fast Growth 100 based on our 2009 – 2011 growth of over 930% per year. » ~ 50% of Technical Staff hold US Government SECRET Clearances.
» Service Disabled Veteran Owned Small Business (SDVOSB).
Summit 7 systems is a premier provider of consulting and implementation services specializing on the Microsoft SharePoint Platform and FAST Enterprise Search.
» Summit 7 Systems was chosen by KMWorld Magazine as one of the top 100 Companies that Matter in Knowledge Management along with companies such as Microsoft, Oracle and IBM.
» Summit 7 Systems was named to the 2011 and 2012 CRN Next-Gen 250 List as a company bringing innovative processes, methodologies and models to the solution provider industry.
» Top 1% of Microsoft Partners Worldwide
» Summit 7 Systems was named #6 on the 2012 CRN Fast Growth 100 based on our 2009 – 2011 growth of over 930% per year. » ~ 50% of Technical Staff hold US Government SECRET Clearances.
SERVICES
SharePoint QuickStart
Information Architecture and Governance Development Upgrade and Migration
Branding and Design (User Experience)
Web Content Management Design and Deployment SharePoint Search
Custom Workflow or Web Part Development InfoPath Forms and Workflows
Performance Baselines and Best Practices Optimization Mapping Business Process to Software Platforms Cloud Services Design and Provisioning
Remote Support Contracts Compliance Quickstart
SOFTWARE PLATFORMS
FAST Enterprise Search SharePoint 2007 SharePoint 2010 SharePoint 2013 Office Platform Sitecore SOLUTION AREAS
SharePoint Platform Solutions Enterprise Search
Enterprise Content Management Internet / Web Content Management Extranet Solutions
Intranet Solutions
Business Process Management Enterprise Project Management Exchange Server
SERVICES
SharePoint QuickStart
Information Architecture and Governance Development Upgrade and Migration
Branding and Design (User Experience)
Web Content Management Design and Deployment SharePoint Search
Custom Workflow or Web Part Development InfoPath Forms and Workflows
Performance Baselines and Best Practices Optimization Mapping Business Process to Software Platforms Cloud Services Design and Provisioning
Remote Support Contracts Compliance Quickstart
SOFTWARE PLATFORMS
FAST Enterprise Search SharePoint 2007 SharePoint 2010 SharePoint 2013 Office Platform Sitecore SOLUTION AREAS
SharePoint Platform Solutions Enterprise Search
Enterprise Content Management Internet / Web Content Management Extranet Solutions
Intranet Solutions
Business Process Management Enterprise Project Management Exchange Server
summit7systems
summit7systems.com/blogs
FOR MORE FROM SUMMIT 7 SYSTEMS…
facebook.com/summit7systems
@summit7systems
POWERSHELL
(& SHAREPOINT)
POWERSHELL
(& SHAREPOINT)
Hey, look here, this ain’t your momma’s command line, Jack! (-Si Robertson)
AGENDA
What is PowerShell? STSADM?...LOL
What are the benefits of PowerShell? What commands will get me started? Variables and Operators
A bunch of other stuff Questions
POWER (RANGER) (TURTLE) SHELL? NOT THIS…
POWERSHELL THIS…
OK, WHAT IS POWERSHELL EXACTLY? Microsoft's task automation framework
› Command Line Shell › Scripting Language
› Built on and integrated with the .NET Framework › (Pretty much C# syntax with a few caveats)
WHERE IS POWERSHELL?
• Built into Windows Server 2008 R2 and Windows 7 • Older OS – Windows Management Framework
• Start > Accessories > Windows PowerShell • SharePoint 2010 Management Shell
STSADM?
Still there and still works
› backwards compatibility
› Allows for portability of existing STSADM batch files and scripts Don’t use this as a crutch! You should do everything in PowerShell.
› PowerShell has full access to the SharePoint API from the command line
STSADM to Windows PowerShell Mapping:
BENEFITS OF POWERSHELL
• Interact with .NET objects directly • Remoting interface
• Reduction in the need of some 3rd party solutions
• Perform administrative functions in bulk, reducing time and effort. • Performance benefits for batch operations and scheduling
• Some SharePoint functions require the use of PowerShell: › Adding Custom Solutions(2010+)
› Resetting the Farm Passphrase (2010+)
› Configuring the State Service Application (2010+)
› Configuring the Publishing Feature’s Super User Accounts(2010+) › Pretty much all Search configuration in 2013
POWERSHELL ISE
• Windows PowerShell Integrated Scripting Environment (ISE)
• Can run commands, write, test, and debug scripts
• Uses color-coding
• Only available with PS 2.0 and above
Better Option (FREE): PowerGUI
POWERSHELL ESSENTIALS Get-Help
Set-ExecutionPolicy
Get-Command (Alias=GCM)
Get-Member (piped command, Alias=GM)
$object | GET-MEMBER (will display the object’s Methods & Properties)
Add-PSSnapIn
EXECUTION POLICY SETTINGS
Restricted - No scripts can be run. Windows PowerShell can be used only in interactive mode.
AllSigned - Only scripts signed by a trusted publisher can be run. RemoteSigned - Downloaded scripts must be signed by a trusted publisher before they can be run.
Unrestricted - No restrictions; all Windows PowerShell scripts can be run.
SEE THE PATTERN?
PowerShell CmdLets are Verb / Noun pairs.
• Set-Something • Get-Something • Enable-Something
Tons of built in Commands
› Spelled CMDLETS
ADD-PSSNAPIN
PowerShell is a blank slate (to SharePoint and FAST) Use Add-PSSnapin to add functionality
(SharePoint Admin Shell)
› Add-PSSnapin Microsoft.SharePoint.PowerShell › Add-PSSnapin Microsoft.FASTSearch.PowerShell
VARIABLES
Begin with $ $integer = 100
$string = “Hello World!”
$web = Get-SPWeb http://portal.com
OPERATORS $integer = 100 $integer = 100+1
Write-Host $integer 101 $integer = $integer * 2
Write-Host “Integer = $integer” Integer = 202 Get-Help about_operators
SPECIAL VARIABLES
Reserved values: $TRUE, $FALSE, $NULL
$_ Current object in the Pipeline
$Args Array of parameters passed to script
$PsCmdLet Current CMDLET or function that is running $Pwd Current Working Directory (not Password) Get-Help about_Automatic_Variables for more info
COMPARISON OPERATORS
Operator Name Example Result
-eq Equal 3 -eq 3 True
-ne Not Equal 3 -ne 3 False
-lt Less Than 3 -lt 3 False
-le Less Than or Equal To 3 -le 3 True
-gt Greater Than 3 -gt 3 False
COMPARISON OPERATORS (CONT.)
Operator Example Result
-like “PowerShell” -like “*shell” True
-notLike Uses Wildcard
-match “9” -match “[0-9]” True
-notMatch Uses Regular Expression
-contains “abc”,”def” -contains “def” True
LOOPING
For
For Each Do While Do Until
FOREACH-OBJECT
Easy Enumeration in Command Line
…Something… | foreach-object { …code…}
› cls
› $web = Get-SPWeb http://portal.contoso.com › $web.Webs | ForEach-Object {$_.Title}
FORMATTING
| Sort-Object
Get-EventLog system -Newest 5 | Sort-Object EventId | Format-Table
SCRIPTS
Allow complex command combinations
Consistently repeat frequent and/or complex tasks Can be parameterized
.PS1 files even though we are 2.0
COMMENTS
We needed another comment format… # for single lines
#This is a comment This is not
<# #> for multiple lines
<# Multiple Line Comments#>
INPUT/OUTPUT
Read-Host (waits for user input)
$var = Read-Host “Prompt Text” Write-Host “Writes this text to the console” Write-Host $var –nonewline
Write-Host (3,9,27,81) –separator “ , “ To write to file:
>> <filename>
| Output-File <filename> |Tee <filename>
WHAT TO REMEMBER
Set-Execution Policy
Get-Help (Get-Help About) Get-Command (Alias GCM) Get-Member
Add-PSSnapIn Aliases
ALWAYS HELPFUL
Google MSDN TechNet PowerGUI
summit7systems
summit7systems.com/blogs
FOR MORE FROM SUMMIT 7 SYSTEMS…
facebook.com/summit7systems
@summit7systems