Download presentation
Presentation is loading. Please wait.
1
PowerShell 101 sharepoint on-premise
GISPUG 8/22/2017
2
Scott Krahn Started sharepoint in 2008 Started powershell in 2012
Lead sharepoint Packaging corporation of America Farm admin 15% Blog:
3
Use examples at your own risk
! Warning ! I am not an expert Use examples at your own risk
4
Overview Add snap-in Variables Gm, The “.” & select
Sharepoint architectural structure Foreach and | logging
5
Add snap-in Snap-in – the enhancement to powershell to gain access to sharepoint components When to use: Windows Powershell running as scheduled tasks Using the ISE (Integrated scripting environment) Shortcut to add: Asnp *share* OR Use sharepoint management console Powershell with sharepoint snap-ins
6
misc Get-help Get-sp??? -examples -detailed -full Tab completion
7
Variables $variable = get-spxxx –parameter “Value” (add filters as desired) Test the command to confirm the correct data is displaying $(get-sp???).mmmppp Mmmppp = method or property Shortcut to creating the variable – if you want a quick farm version Example: $(get-spfarm).version
8
Gm, The “.” and select Using get-member $variable.???
Shows all methods and properties Get-sp??? | get-member $variable | gm $variable.??? ??? = method or property Get-sp??? | select title,url The fields you want to display
9
Sharepoint architectural structure
Get-spfarm – shows the entire farm Get-spserver – shows the servers in the farm get-spwebapplication – shows the web applications in the farm Get-spsite – shows the site collections in the web application Get-spweb – shows the web sites in the site collection
10
Foreach and | Whatever command given – process all the output Same as
$SPWebAPP = get-spwebapplication “ foreach ($Site in $spWebApp.Sites) { #Do whatever you want to do on every collection foreach ($Web in $Site.AllWebs) { #do whatever you want to do in every website in a collection write-host "Title`t`t`t:"$web write-host "Url`t`t`t:"$web.url write-host "RequestAccess `t:"$web.requestaccess write-host "Desription`t`t:"$web.description write-host "WebTemplate`t`t:"$web.webtemplate write-host "LastItemModifiedDate`t:"$web.lastitemmodifieddate write-host "ID`t`t`t:"$web.id write-host "ParentWebId`t`t:"$web.parentwebid write-host "`n“ } $web.dispose() } $SITE.DISPOSE() Same as Get-SPWebApplication “ | Get-SPSite -Limit All | Get-SPWeb -Limit All | Select Title, URL, RequestAccess , Description, WebTemplate, LastItemModifiedDate, ID, ParentWebID
11
logging Setup log location & filename $date = get-date -uformat “%Y%m%d%H%M%S” $Logfile = ".\LOGFILE_$date.txt" Function to call function log($string, $color) { if ($Color -eq $null) {$color = "white"} write-host $string -foregroundcolor $color $string | out-file -Filepath $Logfile –append } Usage (NOTE `n is lowercase n) Log "`nSite Collection: $SiteURL" red
12
demo Foreach & I example
13
Your Examples What do you use powershell for? (updated from input at meeting) Installation My site quota increases via help desk input on a sharepoint list (powershell monitors the list every 5 minutes) Creating content databases Creating sites Deploying features Backup/ restore Merge-splogfile
14
Examples De-activate minimal download strategy feature
Enable site collection feature Site structure report Cleanup disabled users Turn on library versioning Patching process Before: stops crawls, services & disconnects content dbs After: Connects content dbs, starts services & crawls
15
Q&A Thank you
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.