Friday, May 3, 2013

Powershell - Display Event Receivers for a specific Sharepoint List


$web=Get-SPWeb "http://siteURL"
$list=$web.Lists["ListName"]
$list.EventReceivers
$web.Dispose()

Display Names of the Event receivers 

$web=Get-SPWeb "http://SIteURL"
$list=$web.Lists["ListName"]

$list.EventReceivers |ForEach-Object {Write-host $_.Type  $_.Name}
$web.Dispose()

Powershell - Create Posts list to Blog site in Sharepoint


[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$site=new-Object Microsoft.SharePoint.SPSite("http://siteurl/sites/test/")

$web=$site.OpenWeb()

$SPTemplate = $web.ListTemplates["Posts"]


$web.Lists.Add("Posts","Description",$SPTemplate)

Powershell - Delete list from Sharepoint site



[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")

$site=new-Object Microsoft.SharePoint.SPSite("http://siteurl/sites/test/")

$web=$site.OpenWeb()

$list=$web.Lists["ListName"]

$list.Delete()