Tuesday, October 3, 2017

Useful Powershell Commands in SharePoint 2013/2016


To Get the default search index location
 $ssi = Get-SPEnterpriseSearchServiceInstance
 $ssi.Components

It would show  the similar output in which the "Index Location" is the location of search indexes.

Id            : b16c2902-7546-4580-aac8-49ddc822eef5
ServerName    : contoso.com
IndexLocation : C:\Program Files\Microsoft Office Servers\15.0\Data\Office Server\Applications
State         : Ready
DesiredState  : Ready


Clearing all indexes from Search Service Application
 $ssa=Get-SPEnterpriseSearchServiceApplication -Identity "Search Service Application"
$ssa.reset($true,$true)
Where,$True parameter denotes: Disable Alerts & Ignore Timeout error. 



Setting Global Search Center URL in Search Service Application
$ssa=Get-SPEnterpriseSearchServiceApplication -Identity "Search Service Application"
$ssa.SearchCenterUrl = "
http://contoso.com:44494"
$ssa.update()

 
 
Changing the master page on SharePoint sites with PowerShell
web = Get-SPWeb http://portal/sites/collaboration
$web.MasterUrl = "/sites/collaboration/_catalogs/masterpage/custom.master"
$web.Update()
$web.Dispose()


Start the upgrade process on a site collection
Upgrade-SPSite http://<site name>/sites/testsite -VersionUpgrade


Exports a site, list, or library.
Export-SPWeb http://site -Path "site export.cmp"

Import a site, list, or document library in SharePoint 2013
Import-SPWeb -Identity  <SiteURL>  -Path <ImportFileName>

To Convert the authentication mode of a web application
 Convert-SPWebApplication -Identity "https://<webappurl>" -To Claims -RetainPermissions [-Force]


Upgrades a deployed SharePoint Solution
 Update-SPSolution -Identity contoso_solution.wsp -LiteralPath c:\contoso_solution_v2.wsp -GACDeployment


To Install a SharePoint Hosted App in a site
$spapp=  Import-SPAppPackage -Path Path to app -Site URL -Source Source
Install-SPApp -Web URL -Identity $spapp


To Change the visual Elements of Site collection from SharePoint 2010 to SharePoint 2013
Upgrade-SPSite http://<site name>/sites/testsite


Setting up a new URL for existing site collection in web app
Set-SPSiteURL -Identity $site -Url http://contoso.sharepoint.com -Zone Default


To change the ContentType Hub URL in "Managed Metadata Service" Application
Set-SPMetadataServiceApplication -Identity "NYCEDC MMS Application" -HubUri "http://contoso.com:45518/sites/ContentTypeHub/"


To set the interval for creating ULS Log File
PS C:\Users\contoso> Set-SPDiagnosticConfig -LogCutInterval 60

To set the days interval for keeping the ULS log Files.
PS C:\Users\contoso> Set-SPDiagnosticConfig -DaysToKeepLogs 5

To create  a new Managed path under a web application
New-SPManagedPath "applications" -WebApplication http://contoso.com:44495


3 comments: