Post on 27-Nov-2014
description
Training and Consulting: contact@winsmarts.com
SharePoint Powers HellWWW.WINSMARTS.COM@SAHILMALIKFACEBOOK.COM/SAHILMALIKLINKED.IN/SAHIL
Sahil Malik
Training and Consulting: contact@winsmarts.com
SharePoint PowershellWWW.WINSMARTS.COM@SAHILMALIKFACEBOOK.COM/SAHILMALIKLINKED.IN/SAHIL
Sahil Malik
Training and Consulting: contact@winsmarts.com
SharePoint Power sell?WWW.WINSMARTS.COM@SAHILMALIKFACEBOOK.COM/SAHILMALIKLINKED.IN/SAHIL
Sahil Malik
Training and Consulting: contact@winsmarts.com
Training and Consulting: contact@winsmarts.com
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
Training and Consulting: contact@winsmarts.com
C:\>whoami
12xMVP 15xAuthor Pluralsight AuthorFunny and Honest
HTTP://BLAH.WINSMARTS.COM@SAHILMALIK
Training and Consulting: contact@winsmarts.com
PowerShell 3.0
300 new cmdlets
30+ cmdlets removed
PowerShell in SharePoint 2013
Training and Consulting: contact@winsmarts.com
.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?
Training and Consulting: contact@winsmarts.com
Start PowerShell and runAdd-PSSnapin Microsoft.SharePoint.PowerShell
SharePoint 2013 Management Shell
Use PowerShell ISE
3 ways to use PowerShell with SP
Training and Consulting: contact@winsmarts.com
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
Training and Consulting: contact@winsmarts.com
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
Training and Consulting: contact@winsmarts.com
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
Training and Consulting: contact@winsmarts.com
http://www.microsoft.com/resources/TechNet/en-us/Office/media/WindowsPowerShell/WindowsPowerShellCommandBuilder.HTML
PowerShell Command Builder
Training and Consulting: contact@winsmarts.com
PowerShell tricks(some commandline stuff too!)
Training and Consulting: contact@winsmarts.com
Get # of clientconn on #SharePoint WFE w #PowerShell
Get-Counter -Counter 'web service(_total)\current connections' -ComputerName servername
Training and Consulting: contact@winsmarts.com
Kill that synch button
Get-SPSite -limit all | get-SPWeb -limit all | Foreach {$_.Title = $_.Title; $_.ExcludeFromOfflineClient=1; $_.Update()}
Training and Consulting: contact@winsmarts.com
Find lost application pool passwords
cmd.exe /c $env:windir\system32\inetsrv\appcmd.exe list apppool “SharePoint - 80" /text:ProcessModel.Password
Training and Consulting: contact@winsmarts.com
Grid madness – you just have to try this!
$web = Get-SPWeb http://sp$list = $web.Lists | Out-GridView -PassThru
Training and Consulting: contact@winsmarts.com
Find files with matching text
ls -r | ?{$_ | Select-String -Pattern "texttosearch"}
Training and Consulting: contact@winsmarts.com
Save a WSP from central admin as a file
$farm = Get-SPFarm$farm.solutions.item(“solutioname.wsp”).SolutionFile.SaveAs(“c:\whateverfilenameandpath.wsp”)
Training and Consulting: contact@winsmarts.com
CorrelationID Madness on multiple servers
Merge-SPLogFile –Path c:\whateverfile.log –Correlation <correlationID>
Training and Consulting: contact@winsmarts.com
ULS Madness
Get-SPLogEvent | Where {$_.Correlation -Eq "f463c19c-e41f-f09e-a2ef-b8a749edf422" } | ft Message
Training and Consulting: contact@winsmarts.com
Blaming your sysadmins
http://blah.winsmarts.com/2013-12-SharePoint_2013_Diagnostics_Powershell_trick.asp
Training and Consulting: contact@winsmarts.com
Restore accidentally deleted site collections
Get-SPDeletedSite (gives you the ID)Restore-SPDeletedSite (restores it)
Training and Consulting: contact@winsmarts.com
Find orphaned items in a content database
$cdb = get-SPContentDatabase$cdb.Repair($false)
Training and Consulting: contact@winsmarts.com
Find methods and properties on an object
$web = Get-SPWeb http://sp$web | Get-Member
Training and Consulting: contact@winsmarts.com
How is the weather outside?
Invoke-RestMethod -Uri "http://api.openweathermap.org/data/2.5/weather?q=Zagreb"
Training and Consulting: contact@winsmarts.com
Now that you got everything to work .. What PS commands did I use?Get-History | Select –Expand CommandLine | Out-File script.ps1
Training and Consulting: contact@winsmarts.com
Find a new job, through Powershell
stop-computer -force | Get-ADComputer -Filter *
Training and Consulting: contact@winsmarts.com
PowerShell for Office 365
Training and Consulting: contact@winsmarts.com
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 <username@site.com>
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
Training and Consulting: contact@winsmarts.com
Get-Command –Module Microsoft.Online.SharePoint.PowerShell
PowerShell & Office 365
Training and Consulting: contact@winsmarts.com
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
Training and Consulting: contact@winsmarts.com
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)
Training and Consulting: contact@winsmarts.com
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')
Training and Consulting: contact@winsmarts.com
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
Training and Consulting: contact@winsmarts.com
And try this..
iex (New-Object Net.WebClient).DownloadString(“http://bit.ly/e0Mw9w”)
Training and Consulting: contact@winsmarts.com
Found anything useful?
http://blah.winsmarts.com/2014-10-Powershell_Tips_and_Tricks_(and_commandline).aspx
bit.ly/poshtips
Training and Consulting: contact@winsmarts.com
questions?
HTTP://WWW.WINSMARTS.COM/CONTACT.ASPX
@SAHILMALIK
Training and Consulting: contact@winsmarts.com
thank you.
SHAREPOINT AND PROJECT CONFERENCE ADRIATICS ZAGREB, 10/15/2014 - 10/16/2014