Posts

Showing posts with the label powershell

Sharepoint 2010: Deactivate and Activate Feature with Power Shell

Sometimes, you can have trouble with feature upgrade in your site. Especially if you upgrade event receiver, adding new trigger. If you have many sub site using this feature, you can use Power Shell to deactivate and activate feature. This mine: [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") $rootUrl = "http://[SERVERNAME]" $site = Get-SPSite $rootUrl foreach($web in $site.AllWebs) {   $url = $web.Url   if($url -ne $rootUrl){    foreach($feature in Get-SPFeature -Web $url)    {     $featureName = $feature.DisplayName     if($featureName -eq "FEATURE NAME")     {       "Disable and Enable feature $featureName in $web"       Disable-SPFeature -Identity FEATURENAME -Url $url -Confirm:$false       Enable-SPFeature -Identity  FEATURENAME -Url $url       break;     }    }   } }

Sharepoint 2010 Globally Reusable Workflows does not update WF instance in Subsite if re-published: PS Script save me

I defined a Globally Reusable WF for a custom Content Type in root site, with a custom form with InfoPath. I defined a sub site with a list using the global WF template created for its Content Type. Everything works without problems. Now I need to change the WF (both in form and in the process). BUT.. If I edit only the form with InfoPath and then I publish the form, I see correctly the new form in WF on subsites. If I change the WF logic too (any actions) and publish WF (in root site), changes are not perceived by WF on subsites. WF on subsite is updated only if, on subsite, I open WF to change (from browser) and save it. I expect that you can update all WF in subsite using template in root site, without having to reopen and resave each WF in each subsite. I don't understand if it's a bad configuration or a issue on Globally Reusable WF. (I opened question in Technet Forum, here ) UPDATE: Sometimes, I update a WF (form and logic) and logic has been correctly pub...

Sharepoint 2010 - Advanced Settings for Document library in SharePoint 2010 using PowerShell

Image
In this article we will be seeing how to change the Advanced Settings for Document library in SharePoint 2010 using PowerShell and c#. Go to Document Library => Library Settings => General Settings =>Advanced Settings. Using C#: using  (SPSite site = new SPSite("http://serverName:1111/"))             {                 using (SPWeb web = site.RootWeb)                 {                     SPList docLibrary=web.Lists["Doc Library"];                      // Change the advanced settings          ...

Sharepoint 2010 - Associate Workflow to List with Power Shell

I create a new Workflow Template (globally reusable) in root site and I associate it to a List in a Site Template. But I need to update each sub site (created from my Site Template) with the new Workflow. I use PowerShell, to cycle each subsite and associate WF to content type list. This is command I used: [System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") $site=Get-SPSite "http://sharepoint_root_site" foreach($web in $site.AllWebs){    $list=$web.Lists["MyList"]    $taskList=$web.Lists["Workflow Tasks"]    $historyList=$web.Lists["Workflow History"]    $ct=$list.ContentTypes["MyContenType"]    $culture=New-Object System.Globalization.CultureInfo("en-US")    $wfTemplate=$web.WorkflowTemplates.GetTemplateByName("wfTemplate", $culture)    $associationWF=[Microsoft.SharePoint.Workflow.SPWorkflowAssociation]::CreateListContentTypeAssociation($wfTemplate, "MyWFInSubSi...