This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function New-ClientContextWithRetry | |
{ | |
[cmdletbinding()] | |
param | |
( | |
[Parameter(Mandatory=$true, ParameterSetName = "CredentialComponents")] | |
[Parameter(Mandatory=$true, ParameterSetName = "SharePointOnlineCredential")] | |
[string]$ContextUrl, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Invoke-ClientContextWithRetry | |
{ | |
[cmdletbinding()] | |
param | |
( | |
[parameter(Mandatory=$true)][Microsoft.SharePoint.Client.ClientContext]$ClientContext, | |
[parameter(Mandatory=$false)][int]$Delay = 10, | |
[parameter(Mandatory=$false)][int]$RetryAttempts = 5 | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Import-ClientSideObjectModelAssemblies | |
{ | |
[cmdletbinding()] | |
param | |
( | |
[Parameter(Mandatory=$true)][string]$AssemblyPath | |
) | |
begin | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$pattern = "Get-SPSite" | |
$path = "C:\_scripts\SharePoint\OnPrem" | |
$files = Get-ChildItem -Path $path -Recurse -Include "*.ps1", "*.psm1" | |
$scanned = @() | |
foreach( $file in $files ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type -Path "C:\Microsoft.SharePointOnline.CSOM.16.1.6008.1200\lib\net45\Microsoft.SharePoint.Client.dll" | |
Add-Type -Path "C:\Microsoft.SharePointOnline.CSOM.16.1.6008.1200\lib\net45\Microsoft.SharePoint.Client.Runtime.dll" | |
$script:TRACE_LOG_PATH = "C:\_temp\permissions_$(Get-Date -Format "MMddyyyy").csv" | |
$inputFile = "C:\_temp\missing-perms.csv" | |
$credential = Get-Credential | |
function Write-TraceLogEntry |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin Microsoft.SharePoint.PowerShell | |
# get all webs that are not read locked, not provisioned and created more than 5 minutes ago (so we don't delete anything that might be in the middle of provisioning) | |
$unprovisionedWebInfo = Get-SPSite -Limit All | ? { -not $_.ReadLocked } | Get-SPWeb -Limit All | ? { -not $_.Provisioned -and $_.Created.ToLocalTime().AddMinutes(5) -lt (Get-Date) } | SELECT URL, Created, WebTemplate, Provisioned, IsRootWeb | |
# write the data to csv for record keeping | |
$unprovisionedWebInfo | Export-Csv -Path "E:\UnprovisionedWebsToDelete.csv" -NoTypeInformation | |
foreach( $webInfo in $unprovisionedWebInfo ) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$sa = Get-SPEnterpriseSearchServiceApplication | |
# show all the scaled out databases | |
Get-SPServerScaleOutDatabase -ServiceApplication $sa | FT Name, NormalizedDataSource -AutoSize | |
# add the 2013 analytics database to the 2016 farm | |
Add-SPServerScaleOutDatabase -ServiceApplication $sa -DatabaseServer "SQL01\SHAREPOINT" -DatabaseName "SP2013_SERVICE_SEARCH_ADMIN_AnalyticsReportingStore" | |
# get all the scaled out databases |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Test-ExcelServices | |
{ | |
[cmdletbinding()] | |
param | |
( | |
[parameter(Mandatory=$true)][System.Uri]$Uri, | |
[parameter(Mandatory=$false)][System.Management.Automation.PSCredential]$Credential, # if you don't want to connect as the current user | |
[parameter(Mandatory=$false)][int]$CacheThreshold = 5 # minutes | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue | |
$serversNames = Get-SPServer | ? { $_.Role -ne "Invalid" } | % { $_.Address } | |
function Test-RunAsAdministrator | |
{ | |
<# | |
.Synopsis | |
Returns True if the shell is running as an administrator, otherwise false. |