Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
SharePoint PowerShell
1. Training and Consulting: contact@winsmarts.com
SharePoint Powers Hell
WWW.WINSMARTS.COM
@SAHILMALIK
FACEBOOK.COM/SAHILMALIK
LINKED.IN/SAHIL
Sahil Malik
2. Training and Consulting: contact@winsmarts.com
SharePoint Powershell
WWW.WINSMARTS.COM
@SAHILMALIK
FACEBOOK.COM/SAHILMALIK
LINKED.IN/SAHIL
Sahil Malik
3. Training and Consulting: contact@winsmarts.com
SharePoint Power sell?
WWW.WINSMARTS.COM
@SAHILMALIK
FACEBOOK.COM/SAHILMALIK
LINKED.IN/SAHIL
Sahil Malik
10. Training and Consulting: contact@winsmarts.com
PowerShell
Add-PsSnapin Microsoft.SharePoint.PowerShell
Help new-spsite –examples
Help new-spsite –detailed
Help new-spsite –full
$web.Lists | Where-Object {$_.Hidden -eq $false} | format-table Title
15. Training and Consulting: contact@winsmarts.com
Get # of clientconn on #SharePoint WFE w #PowerShell
Get-Counter -Counter 'web service(_total)current connections' -ComputerName servername
16. Training and Consulting: contact@winsmarts.com
Kill that synch button
Get-SPSite -limit all | get-SPWeb -limit all | Foreach {$_.Title = $_.Title;
$_.ExcludeFromOfflineClient=1; $_.Update()}
17. Training and Consulting: contact@winsmarts.com
Find lost application pool passwords
cmd.exe /c $env:windirsystem32inetsrvappcmd.exe list apppool “SharePoint - 80"
/text:ProcessModel.Password
18. 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
19. Training and Consulting: contact@winsmarts.com
Find files with matching text
ls -r | ?{$_ | Select-String -Pattern "texttosearch"}
20. 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”)
21. Training and Consulting: contact@winsmarts.com
CorrelationID Madness on multiple servers
Merge-SPLogFile –Path c:whateverfile.log –Correlation <correlationID>
22. Training and Consulting: contact@winsmarts.com
ULS Madness
Get-SPLogEvent | Where {$_.Correlation -Eq "f463c19c-e41f-f09e-a2ef-b8a749edf422" } | ft Message
23. Training and Consulting: contact@winsmarts.com
Blaming your sysadmins
http://blah.winsmarts.com/2013-12-SharePoint_2013_Diagnostics_Powershell_trick.asp
24. Training and Consulting: contact@winsmarts.com
Restore accidentally deleted site collections
Get-SPDeletedSite (gives you the ID)
Restore-SPDeletedSite (restores it)
25. Training and Consulting: contact@winsmarts.com
Find orphaned items in a content database
$cdb = get-SPContentDatabase
$cdb.Repair($false)
26. Training and Consulting: contact@winsmarts.com
Find methods and properties on an object
$web = Get-SPWeb http://sp
$web | Get-Member
27. Training and Consulting: contact@winsmarts.com
How is the weather outside?
Invoke-RestMethod -Uri "http://api.openweathermap.org/data/2.5/weather?q=Zagreb"
28. 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
29. Training and Consulting: contact@winsmarts.com
Find a new job, through Powershell
stop-computer -force | Get-ADComputer -Filter *
34. 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)
35. 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')
37. Training and Consulting: contact@winsmarts.com
And try this..
iex (New-Object Net.WebClient).DownloadString(“http://bit.ly/e0Mw9w”)
38. 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
39. Training and Consulting: contact@winsmarts.com
questions?
HTTP://WWW.WINSMARTS.COM/CONTACT.ASPX
@SAHILMALIK
40. Training and Consulting: contact@winsmarts.com
thank you.
SHAREPOINT AND PROJECT CONFERENCE ADRIATICS
ZAGREB, 10/15/2014 - 10/16/2014