Show Menu
Cheatography

SharePoint Powershell Developers Usefull Commands Cheat Sheet by

SharePoint powershell usefull commands for developers

General Powershell Commands

List the powershell commands
Get-Co­mmand
Restart IIS Services
iisreset
Reference SharePoint Component
Add-PS­Snapin "­Mic­ros­oft.Sh­are­Poi­nt.P­ow­erS­hel­l"
Returns the names of all users who have the ShareP­oin­t_S­hel­l_A­ccess role
Get-SP­She­llAdmin
Adds a user to the ShareP­oin­t_S­hel­l_A­ccess role for the specified database
Add-SP­She­llAdmin {User account name}
Get the local sharepoint farm
Get-SPFarm
List the web applic­ations
Get-SP­Web­App­lic­ation
List the site collec­tions
Get-SPSite
List the site of a site collection
Get-SPWeb -Site {url of the site}
Removes a user from the ShareP­oin­t_S­hel­l_A­ccess role
Remove­-SP­She­llAdmin -Username {Account name}
List the content databases
Get-Sp­Dat­abase
IISRESET is a command line utility that you can use in powershell but in command prompt also, this can be usefull in some cases for develo­pers.

SharePoint App Deployment

Imports an app package
Import­-SP­App­Package -Path {Path to .spapp file} -Site {Site collection url} -Source {Source of the app}
Installs an instance of an app
Instal­l-SPApp -Web {Web url} -Identity {spapp object returned from import command}
Uninstalls an instance of an app
Uninst­all­-SP­App­Ins­tance -Identity {spapp object returned from get-sp­app­ins­tance command}
Updates the app instance
Update­-SP­App­Ins­tance -Identity $instance -App $spapp
For import app package command, here are the valid values for Source attribute:
- SharePoint Store
- App catalog
- ShareP­oin­tSe­rvice

Timer Job

List jobs of a web applic­ation
Get-SP­Tim­erJob -WebAp­pli­cation {Web applic­ation url}
Start a job
Start-­SPT­imerJob -Identity {Job GUID}
 

Farm Solution Deployment

List the solution of farm solution store
Get-SP­Sol­ution
List the features of the farm
Get-SP­Feature
Add a solution to farm solution store
Add-SP­Sol­ution -Liter­alPath {Path to .wsp file}
Install farm solution to a web applic­ation
Instal­l-S­PSo­lution -Identity {.wsp file name and extension} -WebAp­pli­cation {Web App Url} -GACDe­plo­yment;
Update farm solution to a web applic­ation
Update­-SP­Sol­ution -Identity {wsp file name and extension} -Liter­alPath {Full path of new .wsp file} -GACDe­plo­yment
Uninstall farm solution
Uninst­all­-SP­Sol­ution -Identity {wsp file name and extension} -WebAp­pli­cation {web app url}
Remove farm solution from the store
Remove­-SP­Sol­ution -Identity {wsp file name and extension}
Enable farm solution feature on a site
Enable­-SP­Feature -Identity {Feature Name or ID} -Url {Site url}
Disable farm solution feature on a site
Disabl­e-S­PFe­ature -Identity {Feature name or ID} -Url {Site url}
Installs a SharePoint Feature by using the Featur­e.xml file
Instal­l-S­PFe­ature -path {name of featur­e.xml store in hive}
Uninstalls an installed feature definition
Uninst­all­-SP­Feature -Identity {Feature name}
These commands concern farm solution, for SharePoint Applic­ation commands please see next block.

Services

List SharePoint Service Instances
Get-SP­Ser­vic­eIn­stance -Server {Server name}
Start instance of a SharePoint Service
Start-­SPS­erv­ice­Ins­tance {Service GUID}
Stop instance of a SharePoint Service
Stop-S­PSe­rvi­ceI­nstance {Service GUID}

Logs

List the event logs
Get-Ev­entLog -List
Reads/­queries ULS trace logs
Get-SP­Log­Event
Retrieves Diagnostic Config­uration values
Get-SP­Dia­gno­sti­cConfig
Allows setting Diagnostic Config­uration values
Set-SP­Dia­gno­sti­cConfig
Returns IDiagn­ost­ics­Level2 objects or displays a list of diagno­stics levels
Get-SP­Log­Level
Allows the user to set the trace and event level for a set of categories
Set-SP­Log­Level
Resets the trace and event levels back to their default values
Clear-­SPL­ogLevel
Ends the current log file and starts a new one
New-SP­LogFile
Combines trace log files from all farm servers into a single file
Merge-­SPL­ogFile
All commands who contain SP do actions on SharePoint ULS (Unified Log Service)
 

Comments

No comments yet. Add yours below!

Add a Comment

Your Comment

Please enter your name.

    Please enter your email address

      Please enter your Comment.

          Related Cheat Sheets

          Cisco to Junos Cheat Sheet
          Basic Cisco IOS Commands Cheat Sheet