sharepoint powers hell - sahil malik

40
ining and Consulting: [email protected] SharePoint Powers Hell WWW.WINSMARTS.COM @SAHILMALIK FACEBOOK.COM/SAHILMALIK LINKED.IN/SAHIL Sahil Malik

Upload: sharepoint-and-project-conference-adriatics

Post on 27-Nov-2014

118 views

Category:

Technology


4 download

DESCRIPTION

Really? No way! Must be a typo. Really I am going to talk about PowerShell in this session. And no this is not a PowerShell basics talk. This is a practical hands on talk where Sahil will demonstrate practical usage of PowerShell in both development and production environments. This is a must attend for both Devs and IT Pros.

TRANSCRIPT

Page 1: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

SharePoint Powers [email protected]/SAHILMALIKLINKED.IN/SAHIL

Sahil Malik

Page 2: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

SharePoint [email protected]/SAHILMALIKLINKED.IN/SAHIL

Sahil Malik

Page 3: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

SharePoint Power [email protected]/SAHILMALIKLINKED.IN/SAHIL

Sahil Malik

Page 4: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Page 5: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Definitely IT Pro

Definitely Developer

Once you are good at PowerShell, you will find yourself managing your MP3 library with it. PowerShell is amazing!

Catch a fish for youThis is NOT about command by command overview.

Teach you how to fishThis is about teaching you how to discover the commands and their usage.

Powershell – Intended Audience

Page 6: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

C:\>whoami

12xMVP 15xAuthor Pluralsight AuthorFunny and Honest

HTTP://BLAH.WINSMARTS.COM@SAHILMALIK

Page 7: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

PowerShell 3.0

300 new cmdlets

30+ cmdlets removed

PowerShell in SharePoint 2013

Page 8: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

.NET Framework 4.x Support

Windows PowerShell Workflow

Windows PowerShell Web Access

Improved PowerShell ISE

Better handling of SessionsDisconnected Sessions & Robust Session connectivity

HELPUpdatable help & Online Help

Scheduled Jobs / Task Scheduler Integration

Enhanced Tab Completion

.. And Lots more

What’s new in PowerShell 3.0?

Page 9: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Start PowerShell and runAdd-PSSnapin Microsoft.SharePoint.PowerShell

SharePoint 2013 Management Shell

Use PowerShell ISE

3 ways to use PowerShell with SP

Page 10: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

The command line management story for SharePoint (and many other products)

PowerShell

Add-PsSnapin Microsoft.SharePoint.PowerShell

Help new-spsite –examplesHelp new-spsite –detailedHelp new-spsite –full

$web.Lists | Where-Object {$_.Hidden -eq $false} | format-table Title

Page 11: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Get-SPShellAdmin – determine access to PowerShell

Add-SPShellAdmin – add users to PowerShell

By default, Farm Admin/Local Admin do not have PowerShell Access.

But PowerShell is more forgiving in SharePoint 2013

Managing PowerShell Permissions

Page 12: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Test-SPSite (SharePoint 2010 had Test-SPContentDatabase)

Repair-SPSite

Get-SPSiteUrl - displays URL mappings for a site collection

Start-SPDiagnosticsSession

Stop-SPDiagnosticsSession

Lots of cmdlets new featuresApps, License ManagementBing Maps, Translation Services, Distributed CacheSearch, Upgrade, Request Management, Office Web Apps, BCS

Some new and useful commands

Page 13: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

http://www.microsoft.com/resources/TechNet/en-us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.HTML

PowerShell Command Builder

Page 14: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

PowerShell tricks(some commandline stuff too!)

Page 15: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Get # of clientconn on #SharePoint WFE w #PowerShell

Get-Counter -Counter 'web service(_total)\current connections' -ComputerName servername

Page 16: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Kill that synch button

Get-SPSite -limit all | get-SPWeb -limit all | Foreach {$_.Title = $_.Title; $_.ExcludeFromOfflineClient=1; $_.Update()}

Page 17: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Find lost application pool passwords

cmd.exe /c $env:windir\system32\inetsrv\appcmd.exe list apppool “SharePoint - 80" /text:ProcessModel.Password

Page 18: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Grid madness – you just have to try this!

$web = Get-SPWeb http://sp$list = $web.Lists | Out-GridView -PassThru

Page 19: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Find files with matching text

ls -r | ?{$_ | Select-String -Pattern "texttosearch"}

Page 20: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Save a WSP from central admin as a file

$farm = Get-SPFarm$farm.solutions.item(“solutioname.wsp”).SolutionFile.SaveAs(“c:\whateverfilenameandpath.wsp”)

Page 21: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

CorrelationID Madness on multiple servers

Merge-SPLogFile –Path c:\whateverfile.log –Correlation <correlationID>

Page 22: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

ULS Madness

Get-SPLogEvent | Where {$_.Correlation -Eq "f463c19c-e41f-f09e-a2ef-b8a749edf422" } | ft Message

Page 23: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Blaming your sysadmins

http://blah.winsmarts.com/2013-12-SharePoint_2013_Diagnostics_Powershell_trick.asp

Page 24: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Restore accidentally deleted site collections

Get-SPDeletedSite (gives you the ID)Restore-SPDeletedSite (restores it)

Page 25: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Find orphaned items in a content database

$cdb = get-SPContentDatabase$cdb.Repair($false)

Page 26: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Find methods and properties on an object

$web = Get-SPWeb http://sp$web | Get-Member

Page 27: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

How is the weather outside?

Invoke-RestMethod -Uri "http://api.openweathermap.org/data/2.5/weather?q=Zagreb"

Page 28: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Now that you got everything to work .. What PS commands did I use?Get-History | Select –Expand CommandLine | Out-File script.ps1

Page 29: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Find a new job, through Powershell

stop-computer -force | Get-ADComputer -Filter *

Page 30: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

PowerShell for Office 365

Page 31: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Just like the usual PowerShell except you run the PowerShell command prompt on your machine, and it connects to a server in the cloudConnect-SPOService –url <urltoyourO365site> -Credential <[email protected]>

Get-Help *SPO*

Getting StartedInstall PowerShell 3.0 (you already have it on Win8 or on your SP2013 machine)Install SharePoint Online Management Shell

http://www.microsoft.com/en-us/download/details.aspx?id=35588

PowerShell for Office 365

Page 32: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Get-Command –Module Microsoft.Online.SharePoint.PowerShell

PowerShell & Office 365

Page 33: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Windows PowerShell for SharePoint 2013http://technet.microsoft.com/en-us/library/ee662539(v=office.15).aspx

PowerShell Command Builderhttps://twitter.com/sahilmalik/status/287820194271870976

Index of PowerShell cmdlets for SharePoint 2013http://technet.microsoft.com/library/ff678226(office.15).aspx

SharePoint Online Management Shellhttp://www.microsoft.com/en-us/download/details.aspx?id=35588

Configuring Licensing in SharePoint 2013http://technet.microsoft.com/en-us/library/jj219627(office.15).aspx

PowerShell References

Page 34: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Sound after a long running script..

$([char]7)[console]::beep(500,300)

[console]::beep(440,500) [console]::beep(440,500) [console]::beep(440,500) [console]::beep(349,350) [console]::beep(523,150) [console]::beep(440,500) [console]::beep(349,350) [console]::beep(523,150) [console]::beep(440,1000) [console]::beep(659,500) [console]::beep(659,500) [console]::beep(659,500) [console]::beep(698,350) [console]::beep(523,150) [console]::beep(415,500) [console]::beep(349,350) [console]::beep(523,150) [console]::beep(440,1000)

Page 35: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Speech using PowerShell

Add-Type -AssemblyName System.Speech $synth = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizer$synth.Speak(’If you think this is cool, it only gets better from here')

Page 36: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Drive your sysadmin mad

Add-Type -AssemblyName System.Speech $synth = New-Object -TypeName System.Speech.Synthesis.SpeechSynthesizerInvoke-WebRequest -uri "http://blah.winsmarts.com/Pranks.txt" -OutFile "c:\code\phrases.txt"$phrases = Get-Content "c:\code\phrases.txt"while ($true) { $phrase = Get-Random $phrases ; $synth.Speak($phrase) ;start-sleep 5 }

powershell.exe -windowstyle hidden -scriptname lol.ps1

Page 37: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

And try this..

iex (New-Object Net.WebClient).DownloadString(“http://bit.ly/e0Mw9w”)

Page 38: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

Found anything useful?

http://blah.winsmarts.com/2014-10-Powershell_Tips_and_Tricks_(and_commandline).aspx

bit.ly/poshtips

Page 39: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

questions?

HTTP://WWW.WINSMARTS.COM/CONTACT.ASPX

@SAHILMALIK

Page 40: SharePoint Powers Hell - Sahil Malik

Training and Consulting: [email protected]

thank you.

SHAREPOINT AND PROJECT CONFERENCE ADRIATICS ZAGREB, 10/15/2014 - 10/16/2014