Showing posts with label Powershell. Show all posts
Showing posts with label Powershell. Show all posts

Monday, November 6, 2017

“Alert me” option missing in SharePoint

Issue Description

Recently in our SharePoint 2013 farm, I had noticed that the "Alert Me" button was missing from library tab in 
SharePoint Ribbon.



Resolution

1. Please try this article first -  “Alert me” option missing in SharePoint

2. If this solution dint help, try using the below STSADM or PowerShell command to enable the alerts:

STSADM:
stsadm -o setproperty -pn alerts-enabled -pv true -url http://webappURL
PowerShell
$webapp=Get-SPWebApplication "http://webappURL"
$webapp.AlertsEnabled = $true

$webapp.Update()




Tuesday, February 14, 2017

Create State service application.

A state service application is the container for state service databases.

Using Windows PowerShell

1. Click SharePoint 2013 Management Shell.
2. From the Windows PowerShell command prompt (that is, PS C:\>), type the following command :

New-SPStateServiceDatabase -Name "State Service Database" | New-SPStateServiceApplication -Name "StateServiceApp1" | New-SPStateServiceApplicationProxy -DefaultProxyGroup

Create a Visio Graphics Service service application

Using Central Administration

To create a service application, you must be a member of the farm administrators group.

1. Browse SharePoint 2013 Central Administration.
2. On the SharePoint Central Administration website Home page, in the Application Management section, click Manage service applications.
3. On the ribbon, click New, and then click Visio Graphics Service. Type a name for the new service application.
4. Choose an existing application pool or create a new one.
5. Choose whether to create a Visio Graphics Service Application Proxy (recommended).Click OK.

Using Windows PowerShell

1. Click SharePoint 2013 Management Shell.
2. From the Windows PowerShell command prompt (that is, PS C:\>), type the following command :

New-SPVisioServiceApplication -Name <ServiceAppName> -ApplicationPool <AppPoolName> -AddToDefaultGroup

Example
New-SPVisioServiceApplication -Name "Visio Graphics Service Application" -ApplicationPool "SharePoint Hosted Services" -AddToDefaultGroup

Friday, December 2, 2016

How to find the Workflow Service URL for a SharePoint 2013 Farm using Powershell

To find the registered workflow service address for a SharePoint 2013 farm :

Add-PSSnapin Microsoft.SharePoint.PowerShell
[Void][System.Reflection.Assembly]::loadwithpartialname("Microsoft.SharePoint.WorkflowServicesBase")
$web = Get-SPSite -Limit 1 -WarningAction SilentlyContinue | Get-SPWeb
$wfm = New-Object Microsoft.SharePoint.WorkflowServices.WorkflowServicesManager($web)
$wfm | SELECT *

The above powershell commands returns the below value :

https://abc.xyz.com:12290/SharePoint/

The /SharePoint/ segment of the URL is added by SharePoint during registration process, you should not add segment to your registration URL.

Thursday, December 1, 2016

How to create a SharePoint Subscription Settings Service application through PowerShell

This example assumes that a managed account for DOMAIN\ManagedAccount already exists. 

$AppPool = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account (Get-SPManagedAccount DOMAIN\ManagedAccount)

$App = New-SPSubscriptionSettingsServiceApplication -ApplicationPool $appPool -Name SettingsServiceApp -DatabaseName SettingsServiceDB

$proxy = New-SPSubscriptionSettingsServiceApplicationProxy -ServiceApplication $App

Get-SPServiceInstance | where{$_.TypeName -eq "Microsoft SharePoint Foundation Subscription Settings Service"} | Start-SPServiceInstance

This example creates
- an application pool
- a new subscription settings service application
- a subscription settings service application proxy

- and starts the service instance on the local machine. 

Tuesday, June 28, 2016

How to add a user to Web Application User Policy using PowerShell

To add a user to web application user policy using PowerShell , use the below PowerShell script

$userOrGroup = "i:0#.w|domain\user"
$displayName = "User-NTLM"

$webApp = Get-SPWebApplication("URL")
$policy = $webApp.Policies.Add($userOrGroup, $displayName)
$policyRole = $webApp.PolicyRoles.GetSpecialRole([Microsoft.SharePoint.Administration.SPPolicyRoleType]::FullControl)
$policy.PolicyRoleBindings.Add($policyRole)
$webApp.Update() 

Thursday, March 3, 2016

PowerShell to get the details of Content Sources in the SharePoint Search Service Application

This example retrieves the default content source for the search service application.

$ssa = Get-SPEnterpriseSearchServiceApplication

Get-SPEnterpriseSearchCrawlContentSource -SearchApplication $ssa


Name                           Id    Type                CrawlState CrawlCompleted     
----                               --      ----                   ---------- --------------     
Local SharePoint sites     1     SharePoint           Idle                          
Content Source 1           17    SharePoint           Idle       2/2/2016 2:58:46 PM
Content Source 2            6     SharePoint           Idle       2/2/2016 1:57:00 PM
Content Source 3            12   SharePoint           Idle       2/2/2016 11:57:40 AM
Content Source 4            14   SharePoint           Idle       2/2/2016 11:58:14 AM
Content Source 5            15   SharePoint           Idle       2/2/2016 3:27:58 PM



Monday, January 18, 2016

Common Office Web Apps PowerShell commands

Get-SPWOPIBinding
The Get-SPWOPIBinding returns a list of bindings that were created by using New-SPWOPIBinding on the current SharePoint farm.

Get-SPWOPIBinding

Remove-SPWOPIBinding
The Remove-SPWOPIBinding removes all bindings on the current SharePoint farm.

Remove-SPWOPIBinding -All:$true

New-SPWOPIBinding
The New-SPWOPIBinding creates bindings for all the applications and file name extensions that the WOPI application supports on the current SharePoint farm

New-SPWOPIBinding -ServerName "Server.corp.Contoso.com"


Related Posts – 1 , 2

Tuesday, July 14, 2015

How to delete a corrupted SharePoint list using PowerShell

$web = get-spweb -Identity http://sp2010
$list = $web.lists["corrupted list name"]
$list.AllowDeletion = $true
$list.Update()
$list.Delete()

Friday, June 26, 2015

SharePoint Feature Installation, Activation, Deactivation, and Uninstallation using PowerShell

To install a SharePoint feature with PowerShell
Install-SPFeature FeatureFolderName

To activate a feature
Enable-SPFeature FeatureFolderName -Url http://server/site/subsite

To deactivate a feature
Disable-SPFeature FeatureFolderName -Url http://server/site/subsite

To uninstall a feature
Uninstall-SPFeature FeatureFolderName

Examples:

Activate site collection feature
$site = Get-SPSite http://sp2010
Enable-SPFeature -Identity “FeatureName” -Url $site.Url
$site.Dispose()

Activate site feature
$web = Get-SPWeb http://sp2010
Enable-SPFeature -Identity “FeatureName” -Url $web.Url
$web.Dispose()

Activate site collection features for all site collections in a Web Application
$webApp = Get-SPWebApplication -Identity http://sp2010
$webApp | Get-SPSite -limit all | ForEach-Object {Enable-SPFeature -Identity “FeatureName” -Url $_.Url}

How to Deactivate a SharePoint feature using PowerShell or STSADM

To Disable a SharePoint Feature, you must first determine the scope of the feature. If the scope is Web-based or is a site collection scope, the URL parameter is required. However, if the scope is farm-based, the URL parameter is not required.

Syntax - PowerShell

Disable-SPFeature [-Identity] <SPFeatureDefinitionPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-Url <String>] [-WhatIf [<SwitchParameter>]]

This example disables the "MyCustom" Web site scoped feature at http://somesite.
Disable-SPFeature -identity "MyCustom" -URL http://somesite

This example disables all features in the subsite at http://somesite/myweb.
$w = Get-SPWeb http://somesite/myweb | ForEach{ $_.URL }
Get-SPFeature -Web $w |%{ Disable-SPFeature -Identity $_ -URL $w}

Syntax - STSADM

stsadm -o deactivatefeature
   -filename
   -name <feature folder>
   -id <feature ID>
   [-url] <URL name>
   [-force]

Parameter
Value
Description
filename
A valid file path, such as "MyFeature\Feature.xml"
Path to feature must be a relative path to the 14\Template\Features directory. Can be any standard character that the Windows system supports for a file name.
name
Name of the feature directory, such as “MyFeature”
Name of the feature folder located in the 14\Template\Features directory
id
A valid GUID, e.g.  “11d186e-7306-4902-a825-0eb7609e9280”
GUID that identifies the feature to activate
url
A valid URL, such as http://server_name
URL of the Web application, site collection, or Web site to which the feature is being activated


How to Activate a SharePoint feature using PowerShell or STSADM

To Enable a SharePoint Feature, you must first determine the scope of the feature. If the scope is Web-based or is a site collection scope, the URL parameter is required. However, if the scope is farm-based, the URL parameter is not required.

Syntax - PowerShell

Enable-SPFeature [-Identity] <SPFeatureDefinitionPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-CompatibilityLevel <Int32>] [-Confirm [<SwitchParameter>]] [-Force <SwitchParameter>] [-PassThru <SwitchParameter>] [-WhatIf [<SwitchParameter>]]

This example enables the "MyCustom" site scoped SharePoint Feature at http://somesite.
Enable-SPFeature -identity "MyCustom" -URL http:// sitename

This example enables all SharePoint Features in the subsite at http://somesite/myweb.
$w = Get-SPWeb http://somesite/myweb | ForEach{ $_.URL }
Get-SPFeature -Web $w |%{ Enable-SPFeature -Identity $_ -URL $w}

Syntax - STSADM

stsadm -o activatefeature
   {-filename <relative path to Feature.xml> | -name <feature folder> | -id <feature ID>}
   [-url] <URL name>
   [-force]

Parameter
Value
Description
filename
A valid file path, such as "MyFeature\Feature.xml"
Path to feature must be a relative path to the 14\Template\Features directory. Can be any standard character that the Windows system supports for a file name.
name
Name of the feature directory, such as “MyFeature”
Name of the feature folder located in the 14\Template\Features directory
id
A valid GUID, e.g.  “11d186e-7306-4902-a825-0eb7609e9280”
GUID that identifies the feature to activate
url
A valid URL, such as http://server_name
URL of the Web application, site collection, or Web site to which the feature is being activated

Note : If you try to use the Url parameter on a farm-scoped feature, you receive the following error message:
The feature ‘<feature name>’ applies to the entire farm; the Url parameter cannot be used with farm-scoped features.

Thursday, June 18, 2015

How to Remove a SharePoint subsite through PowerShell

The Remove-SPWeb cmdlet completely deletes the Web specified by the Identity parameter.
Note: Deleting the top level Web site of a site collection causes the entire site collection to be removed.

Syntax

Remove-SPWeb [-Identity] <SPWebPipeBind> [-AssignmentCollection <SPAssignmentCollection>] [-Confirm [<SwitchParameter>]] [-Recycle <SwitchParameter>] [-WhatIf [<SwitchParameter>]]

Example

Remove-SPWeb http://sitename/subsite

This example completely deletes a subsite.

Friday, May 1, 2015

Powershell to list Content Database details for SharePoint Site Collection

Get the Content Database details for SharePoint Site Collection

Get-SPContentDatabase -Site 'http://sharepointsitecollectionurl/'


Id               : xxx1404-b716-xxxx-ba76-9746xxxx                                                                  
Name             : xxx                                                                                                       
WebApplication   : xxx                                                                                                                
Server           :           xxx                                                                                                       CurrentSiteCount : 1

Powershell to list all SharePoint Site Collections and subsites a web application

Get list of SharePoint Site Collections and SubSites

Get-SPSite 'http://sharepointwebapplicationurl/' | Get-SPWeb -Limit All

Powershell to list all SharePoint Site Collections in a web application

Get list of SharePoint Site Collections

Get-SPSite  -Limit All

Powershell to list all SharePoint databases and their sizes

Get list of SharePoint databases and their sizes

Get-SPDatabase | Sort-Object disksizerequired -desc | %{write-host  "Size: $($_.disksizerequired/1mb)MB - Database: $($_.Name)"}

The result will be listed down in the below format.

Size: 5237MB - Database: SharePoint_Config
Size: 3455MB - Database: UsageDB
Size: 2261MB - Database: SharePoint_AdminContent
Size: 204MB - Database: WebAnalyticsStagerDB
Size: 172MB - Database: Sync DB
Size: 155MB - Database: SearchDB_PropertyStore
.
.
.
.
.
Size: 6MB - Database: BusinessDataCatalogDB
Size: 3MB - Database: SecureStoreServiceAppDB
Size: 2MB - Database: StateServiceDB
Size: 2MB - Database: PerformancePointDB

Powershell to list all SharePoint Content Databases in the SharePoint Farm

Get list of all SharePoint Content Databases in the SharePoint Farm

Get-SPContentDatabase

Powershell to list all SharePoint Databases in the SharePoint Farm

Get list of SharePoint Databases in the SharePoint Farm

Get-SPDatabase

Monday, April 13, 2015

How to create a SharePoint State Service application through PowerShell

If you configure the SharePoint service applications manually and not run the configuration wizard, you will miss creating the State Service Application as it is not listed down as a service application option in Central Administration -> Manage Service applications page. ( This Service Application is not available for creation in the New dialog in Central Administration, Manage Service Application)

So it should be created through PowerShell. Below are the commands to create one :

$serviceApp = New-SPStateServiceApplication -Name "State Service Application"
New-SPStateServiceDatabase -Name "SharePoint_Service_State" -ServiceApplication $serviceApp
New-SPStateServiceApplicationProxy -Name "State Service Application Proxy" -ServiceApplication $serviceApp -DefaultProxyGroup