\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Valentin LECERF (iox)} \pdfinfo{ /Title (sharepoint-powershell-developers-usefull-commands.pdf) /Creator (Cheatography) /Author (Valentin LECERF (iox)) /Subject (SharePoint Powershell Developers Usefull Commands Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{0072C6} \definecolor{LightBackground}{HTML}{EFF6FB} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{SharePoint Powershell Developers Usefull Commands Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Valentin LECERF (iox)} via \textcolor{DarkBackground}{\uline{cheatography.com/40809/cs/12476/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Valentin LECERF (iox) \\ \uline{cheatography.com/iox} \\ \uline{\seqsplit{vlecerf}.com} \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Published 11th August, 2017.\\ Updated 11th August, 2017.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{2} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{General Powershell Commands}} \tn % Row 0 \SetRowColor{LightBackground} List the powershell commands & Get-Command \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Restart IIS Services & iisreset \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} Reference SharePoint Component & Add-PSSnapin \seqsplit{"Microsoft.SharePoint.PowerShell"} \tn % Row Count 6 (+ 3) % Row 3 \SetRowColor{white} Returns the names of all users who have the \seqsplit{SharePoint\_Shell\_Access} role & Get-SPShellAdmin \tn % Row Count 10 (+ 4) % Row 4 \SetRowColor{LightBackground} Adds a user to the \seqsplit{SharePoint\_Shell\_Access} role for the specified database & Add-SPShellAdmin \{User account name\} \tn % Row Count 14 (+ 4) % Row 5 \SetRowColor{white} Get the local sharepoint farm & Get-SPFarm \tn % Row Count 16 (+ 2) % Row 6 \SetRowColor{LightBackground} List the web applications & \seqsplit{Get-SPWebApplication} \tn % Row Count 18 (+ 2) % Row 7 \SetRowColor{white} List the site collections & Get-SPSite \tn % Row Count 20 (+ 2) % Row 8 \SetRowColor{LightBackground} List the site of a site collection & Get-SPWeb -Site \{url of the site\} \tn % Row Count 22 (+ 2) % Row 9 \SetRowColor{white} Removes a user from the \seqsplit{SharePoint\_Shell\_Access} role & Remove-SPShellAdmin -Username \{Account name\} \tn % Row Count 25 (+ 3) % Row 10 \SetRowColor{LightBackground} List the content databases & Get-SpDatabase \tn % Row Count 27 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{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 developers.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.52 cm} x{4.48 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{SharePoint App Deployment}} \tn % Row 0 \SetRowColor{LightBackground} Imports an app package & Import-SPAppPackage -Path \{Path to .spapp file\} -Site \{Site collection url\} -Source \{Source of the app\} \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} Installs an instance of an app & Install-SPApp -Web \{Web url\} -Identity \{spapp object returned from import command\} \tn % Row Count 9 (+ 4) % Row 2 \SetRowColor{LightBackground} Uninstalls an instance of an app & \seqsplit{Uninstall-SPAppInstance} -Identity \{spapp object returned from get-spappinstance command\} \tn % Row Count 13 (+ 4) % Row 3 \SetRowColor{white} Updates the app instance & Update-SPAppInstance -Identity \$instance -App \$spapp \tn % Row Count 16 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{For import app package command, here are the valid values for Source attribute: \newline - SharePoint Store \newline - App catalog \newline - SharePointService} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.44 cm} x{4.56 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Timer Job}} \tn % Row 0 \SetRowColor{LightBackground} List jobs of a web application & Get-SPTimerJob -WebApplication \{Web application url\} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Start a job & Start-SPTimerJob -Identity \{Job GUID\} \tn % Row Count 5 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Farm Solution Deployment}} \tn % Row 0 \SetRowColor{LightBackground} List the solution of farm solution store & Get-SPSolution \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} List the features of the farm & Get-SPFeature \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Add a solution to farm solution store & Add-SPSolution -LiteralPath \{Path to .wsp file\} \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} Install farm solution to a web application & Install-SPSolution -Identity \{.wsp file name and extension\} -WebApplication \{Web App Url\} -GACDeployment; \tn % Row Count 13 (+ 6) % Row 4 \SetRowColor{LightBackground} Update farm solution to a web application & Update-SPSolution -Identity \{wsp file name and extension\} -LiteralPath \{Full path of new .wsp file\} -GACDeployment \tn % Row Count 19 (+ 6) % Row 5 \SetRowColor{white} Uninstall farm solution & \seqsplit{Uninstall-SPSolution} -Identity \{wsp file name and extension\} -WebApplication \{web app url\} \tn % Row Count 24 (+ 5) % Row 6 \SetRowColor{LightBackground} Remove farm solution from the store & Remove-SPSolution -Identity \{wsp file name and extension\} \tn % Row Count 27 (+ 3) % Row 7 \SetRowColor{white} Enable farm solution feature on a site & Enable-SPFeature -Identity \{Feature Name or ID\} -Url \{Site url\} \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{8.4cm}{x{4 cm} x{4 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Farm Solution Deployment (cont)}} \tn % Row 8 \SetRowColor{LightBackground} Disable farm solution feature on a site & Disable-SPFeature -Identity \{Feature name or ID\} -Url \{Site url\} \tn % Row Count 4 (+ 4) % Row 9 \SetRowColor{white} Installs a SharePoint Feature by using the Feature.xml file & Install-SPFeature -path \{name of feature.xml store in hive\} \tn % Row Count 7 (+ 3) % Row 10 \SetRowColor{LightBackground} Uninstalls an installed feature definition & Uninstall-SPFeature -Identity \{Feature name\} \tn % Row Count 10 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{These commands concern farm solution, for SharePoint Application commands please see next block.} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{3.92 cm} x{4.08 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Services}} \tn % Row 0 \SetRowColor{LightBackground} List SharePoint Service Instances & \seqsplit{Get-SPServiceInstance} -Server \{Server name\} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} Start instance of a SharePoint Service & \seqsplit{Start-SPServiceInstance} \{Service GUID\} \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} Stop instance of a SharePoint Service & \seqsplit{Stop-SPServiceInstance} \{Service GUID\} \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{8.4cm}{x{5.2 cm} x{2.8 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{8.4cm}}{\bf\textcolor{white}{Logs}} \tn % Row 0 \SetRowColor{LightBackground} List the event logs & Get-EventLog -List \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} Reads/queries ULS trace logs & \seqsplit{Get-SPLogEvent} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} Retrieves Diagnostic Configuration values & \seqsplit{Get-SPDiagnosticConfig} \tn % Row Count 6 (+ 2) % Row 3 \SetRowColor{white} Allows setting Diagnostic Configuration values & \seqsplit{Set-SPDiagnosticConfig} \tn % Row Count 8 (+ 2) % Row 4 \SetRowColor{LightBackground} Returns IDiagnosticsLevel2 objects or displays a list of diagnostics levels & \seqsplit{Get-SPLogLevel} \tn % Row Count 11 (+ 3) % Row 5 \SetRowColor{white} Allows the user to set the trace and event level for a set of categories & \seqsplit{Set-SPLogLevel} \tn % Row Count 14 (+ 3) % Row 6 \SetRowColor{LightBackground} Resets the trace and event levels back to their default values & \seqsplit{Clear-SPLogLevel} \tn % Row Count 17 (+ 3) % Row 7 \SetRowColor{white} Ends the current log file and starts a new one & New-SPLogFile \tn % Row Count 19 (+ 2) % Row 8 \SetRowColor{LightBackground} Combines trace log files from all farm servers into a single file & \seqsplit{Merge-SPLogFile} \tn % Row Count 22 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \SetRowColor{LightBackground} \mymulticolumn{2}{x{8.4cm}}{All commands who contain SP do actions on SharePoint ULS (Unified Log Service)} \tn \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}