This document discusses using PowerShell to automate tasks in SharePoint 2016. It notes that 77 new cmdlets were added and 33 removed compared to previous versions. The presentation covers changes in SharePoint 2016 that enable automation with PowerShell, examples of common tasks that can be automated like site provisioning and reporting, and resources for using PowerShell with SharePoint. Code samples are provided in an accompanying GitHub repository.
2. About Me
• Owner and Consultant at Intelligink
• Trainer for Opsgility
• 10 Years of SharePoint Experience
• 5 Years of Office 365 Experience
• Ran the SharePoint Users Group
in Jacksonville, FL for 5 Years
• Helped start the Cloud Users
Group in Jacksonville, FL this year.
Ben Stegink
http://www.benstegink.com
http://www.intelligink.com
Twitter: @BenStegink
3. About this Presentation
• Assumption is that you have some experience
with PowerShell
• We will cover
• Changes with SharePoint 2016
• Tasks you can Automate with PowerShell to save a lot
of time
• Using PowerShell for reporting on your SharePoint
environment
4. What’s New Different with SharePoint
2016?*
• What’s Been Added?
– 77 cmdlets
– MinRole
– Project cmdlets
• What’s Been Removed?
– 33 cmdlets
– SPEdu cmdlets removed
– Excel Services
*November 2016 CU for SP2013 and SP 2016
5. Addition Details
• 45 SPProject Additions
• Some “hidden” changes with modified
cmdlet parameters
– New-SPConfigurationDatabase
– New-SPSite
• 6 other Categories of cmdlets
• 11 miscellaneous cmdlets
33 Cmdlets removed are SPEdu and Excel
832 SharePoint Cmdlets
Connect-SPConfigurationDatabase
Categories
SP Web Template/SP Site Master
Fast Site Collection Create
Create Site by copying the Site Collection at the Database Level
Only be used with OOTB Site Templates*
Disable-SPWebTemplateForSiteMaster
Enable-SPWebTemplateForSiteMaster
Get-SPWebTemplatesEnabledForSiteMaster
Get-SPSiteMaster
New-SPSiteMaster
Remove-SPSiteMaster
https://absolute-sharepoint.com/2013/06/sharepoint-2013-site-template-id-list-for-powershell.html
SP Site Map
During the beta there were additional parameters to the new-spconfigurationdatabase cmdlet that allowed you to create the site map database – these disappeared with the RTM and so did the database and my guess is they just didn’t remove the cmdlets. There are internal methods to provision the database and it appears to be used by a ton of code to access site collections if the db is present (guessing it’s used for large farms where you have site collections spread over lots and lots of databases and you want a quick way to access the information without storing it in the configuration database so my guess is it’s a performance thing that they introduced for O365 but didn’t fully bake into on-prem). I’m sure there’s a way to get the DB created by calling some method or cmdlet but I couldn’t find one outside of using reflection.
If you want to see the schema of the DB that would get created it’s here: C:\Program Files\Common Files\microsoft shared\Web Server Extensions\16\TEMPLATE\SQL\sitemapdb.sql – you can get a pretty good idea of what it’s purpose is by looking at it.
SP Access Services
Import and Export an Access Services Database. These can be used to move the Access Services database to a new SQL Server
Export-SPAccessServicesDatabase
Import-SPAccessServicesDatabase
SP Apps
Get-SPAppStoreWebServiceConfiguration - https://technet.microsoft.com/en-us/library/mt667915(v=office.16).aspx
Set-SPAppStoreWebServiceConfiguration - https://technet.microsoft.com/en-us/library/mt667916(v=office.16).aspx
Move-SPAppManagementData – not documented…at all
Upgrade-SPAppManagementServiceApplication – not documented…at all
SP Service
These cmdlets can be used to view the status of the SharePoint Service App Services as well as to start/stop them as well as view/set various service properties
Get-SPService
Start-SPService
Stop-SPService
SP Microfeed
Get-SPMicroFeedOptions: Get’s the cache feed settings from the User Profile Application Proxy
Set-SPMicroFeedOptions: Set “rules” for the Microfeed. Things like MaxMentions, MaxPostLength and MaxTags
Copy-SPSideBySideFiles: Copy SideBySide files when using PowerShell script in zero downtime patching instead of PSConfig.exe. Or if PSConfig.exe fails on the SiteBySide copy, you can use the cmdlet to do it.
If the update process fails for any reason, you can run the Copy-SPSideBySideFiles cmdlet to restore the state of the update. For additional information about Side by Side files, see Copy-SPSideBySideFiles.
You should enable the side-by-side file copy process before you Upgrade. Running in side-by-side ensures that all the web front ends in the farm serve the same static content during the upgrade, even if static files on a given WFE are being upgraded or replaced.
Remove-SPCentralAdministration: Remove CA from the local server
Merge-SPUsageLog: Gather information from the Usage Log across the entire farm. Can filter and aggregate logs based on specific information
Export-SPTagsAndNotesData: Export the Tags and notes from the SharePoint NewsFeed to a .zip file. Tags and Notes are written into two separate files.
Get-SPConnectedServiceApplicationInformation: Get’s the health of a service application proxy
Get-SPInsightsConfig: returns the uploader.xml and dataloader.exe.config from configuration database. Then you can make updates to the xml and apply the updates.
This is used in a SharePoint Hybrid Auditing
Migrate-SPDatabase: No Documentation, Appears to be able to be used to migrated SP2013 Databases to SP2016 (both Service Application DBs as well as maybe content databases)
Reset-SPSites: Performs a Sync of the content databasea nd config database. Make sure all sites in Content DB are in Config and all Site collectsion on Config DB actually exist in the content DB
Set-SPDefaultProfileConfig: Sets the MySitesPublicEnabled property to true or false
Set-SPServer: Set’s the role of the SharePoint Server (think minrole)
Upgrade-SPProfileServiceApplication: Upgrades the User Profile Service Application
SharePoint DNS is hosted by Microsoft, you can’t change the URL of SharePoint to anything other than [tenant].sharepoint.com