Pages

Showing posts with label PowerShell. Show all posts
Showing posts with label PowerShell. Show all posts

Tuesday, July 18, 2023

Site Collection Quotas and Locks greyed out in Central Administration

 Problem 

One our site collections in SharePoint 2016 farm was in read only mode. When I navigate through Central administration the options under Site Collection Quotas and Locks are greyed out and I was not able to change the options. 

Solution 

To remove the read only I ran the below PowerShell script and it worked.


$site = Get-SPSite "siteurl"

$site.GetType().GetProperty("MaintenanceMode").GetSetMethod($true).Invoke($site, @($false))


Thursday, May 14, 2015

Web Designer Galleries section is missing on SharePoint Online

Problem

Recently I had to create a trial Office 365 account for a demo purposes. But there are some sections such as “Web Designer Galleries”, “HTML Field Security”, “SharePoint Designer Settings” (under Site Collection Administration section) were missing on the setting page of the SharePoint site.

Also I was not able to upload JavaScript file in my document libraries. 

So here are the steps for resolving the issue.

Solutions

Method 01

Step 01: Go to Admin panel

image

Step 02: Go to SharePoint admin center by selecting SharePoint from the left navigation

 001Step 03:  There go to the setting page

002Step 04: From there allow Custom Script

image

There is a  note saying “changes to this setting might take up to 24 hours to take effect.” So here is the power shell command to do that for immediate effect.

Method 02

Step 01: Open the SharePoint Management shell

Step 02: Type the below command to connect with SharePoint Admin Center in management shell. You have to replace your admin center url which is in line 1.

  1. $spadminurl = "https://suhailj-admin.sharepoint.com/"
  2. connect-sposervice -url $spadminurl

Step 03: You will be asked to enter user name and password.

image

Step 04: Enter the below commands. You have to mention your site collection url where you need the sections.

  1. $spsiteurl = "https://suhailj.sharepoint.com"
  2. Set-SPOsite $spsiteurl -DenyAddAndCustomizePages 0

 

Conclusion

Immediately you can see the web designer galleries in setting page; and I was able to upload JavaScript files in my document libraries.

image

Wednesday, January 1, 2014

SharePoint 2013 Search is not working - "Search has encountered a problem that prevents results from being returned"

Introduction

Happy New Year! I was working on SharePoint search where our client had a requirement on retrieving data through SharePoint search. Hopefully my upcoming posts will be related to SharePoint Search Server.

Problem Background

Suddenly my Search Service stopped working and it didn’t return results. My “Search Results” Web part show the error with the message “Search has encountered a problem that prevents results from being returned. If the issue persists, please contact your administrator.” See the screenshot below. Please note that I couldn’t capture the screenshots from my server and the screenshots are taken from the net.

Then when I try to open Search Service Application there also, I was able to see some error message.

Under “System Status (Name of Search application service => search administration => System Status)”; “Searchable items” showed “All Errors”.

And also Search Application Topology showed a error message as 
“Search Issue Unable to load the topology from the Search Administration component”. Ideally this should show something like this (See the below Screenshot).


When I try to see ULS log; I got the below error log

Content Plugin can not be initialized - list of CSS addresses is not set.


Solution Background

The issue is that SharePoint Search is unable to load the topology from the Search Administration component.

Solution 01

Recreate the Search Service Application using the Central Administration

Solution 02

The first Option didn't work for me. So I created the Search Service Application through the PowerShell which worked fine. Please go to the below Url and you can find the script to create service application from the scratch. http://melcher.it/2012/07/sharepoint-2013-create-a-search-service-application-and-topology-with-powershell/

Conclusion

There are plenty of suggestions on msdn. Please check for this solution as well. If this works say thanks to Maximilian Melcher (http://melcher.it/about-me/)

Sunday, August 4, 2013

"MissingAssembly" Error after Migrating from SharePoint 2010 to SharePoint 2013

Introduction

As I mentioned in a earlier post; I started working on Migration from SharePoint 2010 to SharePoint 2013 and power shell scripting.

Problem Background


After the migration we TEST-SPContentDatabase -Name "Name of the Content Database" -WebApplication "Name of the WebApplication"  > C:\test.txt in order to test the migrated database. 

In the text file we were able to find some migrated issues. One of that is MissingAssembly. So here I'm going to show how to solve it. 

Solution 

Please note that I used Phil Childs post in order to achieve this. http://get-spscripts.com/2011/08/diagnose-missingwebpart-and.html. I have automated by getting the missing assembly details to a text file and then getting the necessary details from the text file and removing the Event receiver, For more information please read Phil's post. 

Here is the code. 

You have to change the lines which are bold and italic, according to your data. 
Add-PSSnapin Microsoft.SharePoint.PowerShell
function Run-SQLQuery ($SqlServer, $SqlDatabase, $SqlQuery)
{
   $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
   $SqlConnection.ConnectionString = "Server =" + $SqlServer + "; Database =" + $SqlDatabase + "; Integrated Security = True"
   $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
   $SqlCmd.CommandText = $SqlQuery
   $SqlCmd.Connection = $SqlConnection
   $SqlAdapter = New-Object System.Data.SqlClient.SqlDataAdapter
   $SqlAdapter.SelectCommand = $SqlCmd
   $DataSet = New-Object System.Data.DataSet
   $SqlAdapter.Fill($DataSet)
   $SqlConnection.Close()
   $DataSet.Tables[0]
}

Run-SQLQuery -SqlServer "Name of the SQL Server" -SqlDatabase "Name of the Content DB" -SqlQuery "SELECT * from EventReceivers where Assembly = 'Virtusa.Vplus.Leaderboards.EventReceivers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c3202aa47f1aa64d'" | select Id, Name, SiteId, WebId, HostId, HostType | Format-List | out-file -filepath "C:\Data.txt" 


$textData = Get-Content C:\Data.txt

for($i=0; $i -le $textData.Length - 1; $i++)
{
   $test = $textData.Get($i)
   if($test.StartsWith("Id"))
   {
       $test -match "Id       : (?.*)"
       $Id = $matches['id']
       Write-Host "Id: $Id"
    }
    if($test.Contains("SiteId"))
    {
      $test -match "SiteId   : (?.*)"
      $SiteId = $matches['SiteId']
      Write-Host "SiteId: $SiteId"
    }
    if($test.Contains("WebId    : "))
    {
       $test -match "WebId    : (?.*)"
       $WebId = $matches['WebId']
       Write-Host "WebId: $WebId"
    }
    if($test.Contains("HostId   : "))
    {
       $test -match "HostId   : (?.*)"
       $HostId = $matches['HostId']
       Write-Host "HostId: $HostId"
       try
       {
        $site = Get-SPSite -Limit all | where {$_.Id -eq $SiteId}
        $web = $site | Get-SPWeb -Limit all | where {$_.Id -eq $WebId}
        write-Host "Web Url:" $web.Url
        write-Host "Site Url:" $site.Url
        $list = $web.Lists | where {$_.Id -eq $HostId}
        write-Host "List Name:" $list.Title

        $er = $list.EventReceivers | where {$_.Id -eq $Id}
        $er.Delete()
        write-Host "Deleted Successfully"

        }
        catch
        {
         Write-Host "Cannot Delete"
        }
   }
     
}

Conclusion

  • Running this script will take a long time. So please schedule the time frame before start running the script. 

Wednesday, July 24, 2013

Install PowerShell ISE in Windows Server 2008 R2

Introduction

I was assigned to write some PowerShell Scripting for our SP2010 to SP2013 migration. But I couldn't find any tool to write the script by default. My Tech Lead showed me how to install  PowerShell ISE  in my machine. I'm presenting you that. 

Solution 

Here are the simple steps to install PowerShell ISE. This can be achieved my enabling the feature in Windows Server 2008 R2. 


  • Open Server Manager (Start -> Administrative Tools -> Server Manager)
  • Click on "Features" at the left
  • Click on "Add Features" on right hand side.
  • Then you will prompt to select some options. 
  • There check (select) "Windows PowerShell Integrated Scripting"

  • Click Next and you will find PwerShell ISE ready on All Programs. 

Conclusion

  • Happy Scripting :)