Sunday, June 22, 2014

Cancel Workflow Instances using powershell script

Hi All,

Recently, I worked on the requirement to terminate the running workflow instances associtated to the specific list using powershell script.

I used WorkflowManager and then Cancel method with passiing the workflow instance class,

Here  I terminated the workflows for which the workflow status is running.

here is the script.

 
#Site URL
$siteurl=Read-Host "Enter Site URL"
$web = Get-SPWeb $siteurl
$web.AllowUnsafeUpdates = $true;    

#List Name
$listname=Read-Host "Enter list Name"
$list = $web.Lists["$listname"];

if($list -ne $null)
{
# Iterate through all Items in List and all Workflows on Items.         
foreach ($item in $list.Items) {
foreach ($wf in $item.Workflows) {

#Cancel Workflows      

if($wf.InternalState - eq 'Running')
{  
[Microsoft.SharePoint.Workflow.SPWorkflowManager]::CancelWorkflow($wf);      
}
}
}
$web.Dispose();
}
else
{
 write-host "List does not exist"
}

Specific feature Activated sites report using Powershell

Hi All,

when you got the requirement to know the list of site collections where a specific feature got activated at the site collection level, the below script will be helpful.

For example, to know the list of site collection where the Nintex wokrflow got activated, use the below script.

 
$GC = Start-SPAssignment

$sites=$GC | Get-SPSite -Limit All


foreach($site in $sites)

{

$feature=Get-SPFeature -Site $site | Where-object {$_.DisplayName -eq "NintexWorkflow"}

if($feature -ne $null)
{
  write-host "Feature activated at site" $site.Url

}
$site.dispose()
}

Stop-SPAssignment $GC
 
If you want the spcific publishing feature or custom feature activated site collection list, replace the feature display name with the custom one.
 
 

Tuesday, September 24, 2013

SharePoint Health Analyser automated mail using Powershell

Hi guys,

Got a requirement to send the farm health report to the farm adminstrators group to get the updates automatically throgh the mail.

After some research, I found the basic power shell script which pulls the data from Health Reports list in the central administration web application

I modified and updated the script to get the severity incidents in the HTML tabular form ,

We can execute the script with task scheduler for automation.

Content Query web part --Querying multiple specific lists

Hi guys,

How to query the data from multiple lists in SharePoint using content query webpart?

 I have a simple requirement to display the latest 5 document links from multiple document libraries in the current site.

 In general, share point out of the box feature provides the way to query the data from a particular list or all the lists/document libraries in a site or entire site collection.

 If you want to query the data from multiple specific lists, you have to do in in the below way.

 Add the content query webpart to the page,by editing the page and it comes in Content Roll up category. Note- if you are not able to see content query webpart in content roll up category, then your site's publishing feature is not activated. Activate that feature at the site collection level and also at the site level [make sure you have site collection administrator rights.]

 In the content query web part tool box section, select the radio button, that shows "select all the lists/document libraries in the site" and do the remaining filter and sort options, presentation things as per your requirement.

 Finally click Apply button ,then save the page and do the export web part.

 Open the .webpart file after you export it, modify the .webpart file in designer and then find the below property "ListsOverride ".

Get the List GUIDs from the list settings page, for which you want to query the lists.

 Modify that tag similar to the below one.









SharePoint 2010 List color codes indiacator using HTML calculated columns

Hi guys,

I have the requirement to build the dashboard designer based on the data from the list. After research on the google, I am able to find the simple way to achieve it using html calculated columns.

Below is the brief description about it for reference.

For example, you have the choice field to show the field "Kickoff" status to green for in progress, red for delay and yellow for hold on.

I created the calculated column to name it as "KICKOFF" and wrote the calculated formula as follows.

KICKOFF: ="
"

Once the user selects the Kickoff field to green from choice dropdown, the dashboard field will be updated with green bullet.

Similarly for other fields, you can write the html calculated fields easily based on the choice specified in the original field.

PRESENT: ="
"

In above one ,if the choice field "Final presentation" selected by user is Red, the calculated field show red bullet in dash board.

Once you insert the list view webpart in the page, modify the view of list to display the calculated fields .

After that , your job is not completely done.  You have to modify the columns value in sharepoint designer.

Open the list view webpart in designer and select the calculated field, then go to properties and then write

xsl:value-of disable-output-escaping="yes"

Save and close the page. Refresh the page in webpage and see the color dashboard.

Saturday, September 14, 2013

Dataform webpart throws error XSLT timeout error

In the data form webpart, if the xslt transformation takes more than one second, the stack overflow exception would be thrown and error message displayed to the user.

To increase the transformation time out, the below power shell script is required.



Activating FAST search feature using power shell script

Hi Guys,

I had a chance to check whether the fast search feature is activated on your site collection or not using power shell script.

If you navigate to the below url, then you are able to find the fast search feature status
http://sitecollectionurl/_layouts/contextualkeywordmanagement.aspx



Fast search feature is the hidden one, where you need to activate that one using power shell console only through farm administration rights.

Here is the powershell command to know the features activated on your site collection

Get-SPFeature -site siteurl |sort displayname.

If you do not find the feature named "Search Extensions" in the activated features list, you need to activate the hidden feature manually using Fast search feature GUID.

Enable-SPFeature -ID "5EAC763D-FBF5-4d6f-A76B-EDED7DD7B0A5" -site sitecollectionurl