• No results found

POWERSHELL (& SHAREPOINT) This ain t your momma s command line!

N/A
N/A
Protected

Academic year: 2021

Share "POWERSHELL (& SHAREPOINT) This ain t your momma s command line!"

Copied!
38
0
0

Loading.... (view fulltext now)

Full text

(1)

POWERSHELL

(& SHAREPOINT)

(2)

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

(3)

» 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.

(4)

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

(5)

summit7systems

summit7systems.com/blogs

FOR MORE FROM SUMMIT 7 SYSTEMS…

facebook.com/summit7systems

@summit7systems

(6)

POWERSHELL

(& SHAREPOINT)

(7)

POWERSHELL

(& SHAREPOINT)

Hey, look here, this ain’t your momma’s command line, Jack! (-Si Robertson)

(8)

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

(9)

POWER (RANGER) (TURTLE) SHELL? NOT THIS…

(10)

POWERSHELL THIS…

(11)

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)

(12)

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

(13)

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:

(14)

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

(15)

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

(16)

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

(17)

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.

(18)

SEE THE PATTERN?

PowerShell CmdLets are Verb / Noun pairs.

• Set-Something • Get-Something • Enable-Something

Tons of built in Commands

› Spelled CMDLETS

(19)

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

(20)
(21)
(22)

VARIABLES

Begin with $ $integer = 100

$string = “Hello World!”

$web = Get-SPWeb http://portal.com

(23)

OPERATORS $integer = 100 $integer = 100+1

Write-Host $integer  101 $integer = $integer * 2

Write-Host “Integer = $integer”  Integer = 202 Get-Help about_operators

(24)

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

(25)

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

(26)

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

(27)
(28)

LOOPING

For

For Each Do While Do Until

(29)

FOREACH-OBJECT

Easy Enumeration in Command Line

…Something… | foreach-object { …code…}

› cls

› $web = Get-SPWeb http://portal.contoso.com › $web.Webs | ForEach-Object {$_.Title}

(30)

FORMATTING

| Sort-Object

Get-EventLog system -Newest 5 | Sort-Object EventId | Format-Table

(31)

SCRIPTS

Allow complex command combinations

Consistently repeat frequent and/or complex tasks Can be parameterized

.PS1 files even though we are 2.0

(32)

COMMENTS

We needed another comment format…  # for single lines

#This is a comment This is not

<# #> for multiple lines

<# Multiple Line Comments#>

(33)

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>

(34)
(35)

WHAT TO REMEMBER

Set-Execution Policy

Get-Help (Get-Help About) Get-Command (Alias GCM) Get-Member

Add-PSSnapIn Aliases

(36)

ALWAYS HELPFUL

Google MSDN TechNet PowerGUI

(37)

summit7systems

summit7systems.com/blogs

FOR MORE FROM SUMMIT 7 SYSTEMS…

facebook.com/summit7systems

@summit7systems

(38)

POWERSHELL

(& SHAREPOINT)

References

Related documents