Olsberg Scripts

This is a collection of PowerShell scripts I have created working with SharePoint and SQL. Most of these scripts focus on SharePoint 2013, but there are some which are general in nature, and one for creating robust SQL backups. I have more scripts to add, but I am taking some time to clean them up first.

Here are the custom functions available in my scripts:

Change-SPMasterPage -The Change-SPMasterPage function will change the master page on every site within a SharePoint 2010 and 2013 site collection. It can be run against an entire web application, a content database, or a single site collection.

Clean-SPRecycleBins - The Clean-SPRecycleBins function will empty the stage one and stage two recycle bins on a site collection. Can be run against an entire web application or just one site collection.*Clear-

SPFileSystemCache - The Clear-SPFileSystemCache function will stop the timer service, clear the xml files, set the ini file contents to '1', and start the timer service. It does this on all servers in a SharePoint farm.

Create-SQLScript-Backups - The Create-SQLScripts-Backups function creates a simple TSQL script that you can run on your SQL servers. It will create a script for the backup devices, a full backup, a differential backup, and a tlog backup. Each of these jobs is multi-step and has logic to move to the next correct step upon success or failure of a step.

Copy-ProfileFileToSpServers - The Copy-ProfileFileToSpServers function will copy a profile.ps1 file that you specify to all SharePoint servers in a farm.

Copy-ProfileFileToCurrentSpServer - The Copy-ProfileFileToCurrentSpServer function will copy a profile.ps1 file that you specify to the SharePoint server you are currently on.

Delete-ProfileFileFromSPServers - The Delete-ProfileFileFromSPServers function will delete the profile.ps1 file from all SharePoint servers in a farm.

Get-SPUserPermissionAudit -The Get-SPUserPermissionAudit function will audit the security of groups and users on a SharePoint site collection. This includes all subsites, lists, and items.

iisreset-AllSpServers - The iisreset-AllSpServers function will perform an "iisreset /noforce" on all SharePoint servers in a farm.

Rename-ContentType - The Rename-ContentType function will rename a content type on a SharePoint farm.

Restart-AllSpServers - The Restart-AllSpServers function will restart every SharePoint server in the farm.

Restart-SpTimerServiceOnFarm - The Restart-SpTimerServiceOnFarm function will restart the SharePoint timer service on all servers in a SharePoint farm.

Search-SPFeatureFilesForGUID - The Search-SPFeatureFilesForGUID function will search the file system path for the SharePoint features folder for a GUID.

Search-FolderForString - The Search-FolderForString function will recursively search a file system path for files contianing a string.

Set-ContentDbLimits - The Set-ContentDbLimits function will change the Warning site count and/or the max site count on a database. Alternatively, you can 'lock' a database which sets the warning site count to zero, and the maximum site count to what the current site count is, which is a better option that setting the database to offline.

Set-ContentDbStatus - The Set-ContentDbStatus function will set a content database to offline or online status.

Search-SPLogsForString - The Search-SPLogsForString function will search the ULS logs for a string, such as a correlation ID. It will return the server name and log name that contains that string. This makes it easy to find out which server has the logs you need to review. You can search for logs in the last x hours, logs within a specified start and end time, a specific time, or the last two logs files.

Last edited Sep 29, 2014 at 6:15 PM by michaelolsberg, version 10