Delete site collection by reading csv File

Below script will read from csv file and delete the site collection.

Create CSV file with column name SiteUrl and add the list of sitecollection url.

Create file deleteSitecollection.ps1 and add the below code.

#Read the CSV file  

$CSVData = Import-CSV -path "D:\Data.csv"  

foreach($row in $CSVData)
{ 
write-host "Deleteing Site " + $row.SiteUrl  
remove-Spsite -identity $row.SiteUrl -confirm:$false  
Write-host ""
Write-host "Pausing for 600 seconds..."
Sleep 600
} 

It’s always recommended to put delay between deleting site collections. This is due to the fact that SQL server will not get overwhelmed by sudden deletion of large amount of data. So even though you can do it in one go, it is advised to wait for some time like at least 10 mins between each delete.delete.  we added sleep 600 to wait before next site collection delete.

Advertisements

Change title of new /edit/ view list form

In SharePoint 2010 whenever you do any operation with respect to list like add,view and edit,it open in modal dialog box.

We had one of the requirement as to remove hyphen(-) from the modal title.

1

Edit default new form web part and add content editor web part.

2

create txt file add the below snippet and make refrence to the content editor

<script type=”text/javascript” src=”https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js”></script&gt;
<script language=”javascript” type=”text/javascript”>

$(document).ready(function () { ExecuteOrDelayUntilScriptLoaded(CustomAction, “sp.js”); });

function CustomAction(){
var oldText= parent.document.getElementById(“dialogTitleSpan”);
var newText=oldText.textContent.split(“-“)[0];
SP.UI.UIUtility.setInnerText(parent.document.getElementById(“dialogTitleSpan”), newText);
}

</script>

Save and close the page.

Now open the add new form it will have title without hyphen

3

Auto Populate username in list form using JavaScript Sharepoint

1.open default new form/edit form  under edit form web parts

listedit

2.add the script editor web part on the web page.

script editor

3.click on edit snippet inside script editor webpart and add the below code

embedcode

click on insert. after click stop editing page.

now whenever you open new form it will have current user as populated in peoplepicker.

listform

<script src="/my/Style%20Library/jquery-1.11.2.js"></script>
<script language="javascript" src="/my/Style%20Library/jquery.SPServices-0.6.2.js" type="text/javascript">
</script>  
<script language="javascript" type="text/javascript"> 
$(document).ready(function() { 
var userName= $().SPServices.SPGetCurrentUser(); 
$(".sp-peoplepicker-initialHelpText.ms-helperText").text(""); 
$(".sp-peoplepicker-topLevel").val(userName); 
 $(".sp-peoplepicker-topLevel").text(userName); 
 }); 
</script> 

Note.Make sure page will have reference of jQuery.SPServices-0.6.2.js and jQuery-1.11.2.js files. you can add any where in web and add reference to a page.

Get Distinct record from sharepoint list for specific time

using (SPSite objSite = new SPSite(“siteurl”))
{

using (SPWeb oWeb = objSite.OpenWeb())
{

SPList oList = oWeb.Lists[“test”];
SPQuery objspquery = new SPQuery();
objspquery.Query = string.Format(“{0}”, “09/16/2014”);

SPListItemCollection objcoll = oList.GetItems(objspquery);
DataTable dt = new DataTable();
dt = objcoll.GetDataTable();

// find the list of unique/distinct users who submitted the entries against the given period
DataView view = new DataView(dt);
DataTable distinctUsers = new DataTable();
distinctUsers = view.ToTable(true, “UsernName”);

//Number of users(distinct/unique) against the given period & Team.
DataView view1 = new DataView(dt);
DataTable distinctUsersTeam = new DataTable();
distinctUsersTeam = view.ToTable(true, “UsernName”, “TeamName”);

}

}

List :
TestTlist

Result1:
result1

Result 2:

result2

Cant retract solution timer job “name of the timer job” cannot be deserialized because it doesnot have a public default constructor.

//

I have encountered error while upgrading one of my custom solution using power-shell. The error was “Cant  rectract solution timer job “name of the timer job” cannot be deserialized because it doesnot have a public default constructor”.

 

TimerJobError

To resolve this issue steps are as follows:

1.Find out DLL name of timer job that causing error.(Open timer job solution =>right click =>open folder in window explorer =>Bin=>Debug)

2.Go to gac( “c:\Windows\assembly” can be varies) locate your dll and uninstalll it.

3. do iisreset

 

Note:You should have admin privileges to uninstall dll from GAC.