Saturday, July 26, 2014

SharePoint migration – designer workflow runs twice every time

Migrating from SharePoint 2007 to 2013, SharePoint designer 2007 workflows migrated correctly and workflows are working as expected.

We can’t use SharePoint 2007 list template directly to create the list templates. To do that we have to save the list as a template and need to use that template to create the list.

In SharePoint 2007 site we had a workflow that sends email and update the list data depending on the details created/updated. I have attached the SharePoint designer workflow to the list. But after attaching the workflow, whenever list item added/updated to the list, it is firing twice.

After checking that some time and trail and errors I got the fix for the problem. To do that we have to pause some duration in the workflow beginning. We can make this as 1 min because the workflow timer job will take 5 min and by updating the ‘pause for duration’ value we can change the value by using job definitions in Central Administration.

Thursday, July 24, 2014

SharePoint Managed Accounts error: Managed Account could not be deleted because other objects depend on it.

After deleting all the service applications and managed account from SharePoint server by using following PowerShell commands,

Get-SPManagedAccount | Where-Object {$_.UserName -eq "Domain\Username"} | Remove-SPManagedAccount

By running the command I got an error saying that,

Remove-SPManagedAccount : An object in the SharePoint administrative framework, “SPManagedAccount Name=managed-account-S-1-5-21-2912393494-653453454-43454533245-4324″, could not be deleted because other objects depend on it. 

We can see this error because the service error we are going to delete is having dependencies. In my case iam using same account for User Profile Service.

By using following commands, we can release the dependencies on the service account.

Get-SPServiceApplicationPool | Where-Object {$_.Name -eq "User Profile Service"} | Remove-SPServiceApplicationPool

After running the command we have to delete the account by running the following command,

Get-SPManagedAccount | Where-Object {$_.UserName -eq "Domain\Username"} | Remove-SPManagedAccount

Hope this helps.

SharePoint – Delete Orphaned sites using PowerShell commands

We can delete the orphaned site in SharePoint environment that we are trying to provision the project server application. To remove orphaned site we have to un-provisioned and then delete the site.

We can delete the site by using following PowerShell commands,

Get SharePoint service application by using Get-SPServerviceApplication command
We can see the list of GUID’s. Get the service application specific to the orphaned site by using get-spserviceapplication command

$serviceApp = Get-SpServiceapplication | ? {$_.Id -eq "GUID of the Service App"}

Get the Site collection by using the service app

 $siteCollection = $serviceApp.SiteCollection

Get the site from Site Collection and delete the site by using the following commands,

$site = $siteCollection.Sitecollection | where {$_.SiteID -eq "< Guid>"}

Wednesday, July 16, 2014

SSRS report – SharePoint list error: an error occurred when accessing the specified SharePoint list. The connection string might not be valid

While creating the report by using SharePoint list, I got an error saying that “an error occurred when accessing the specified SharePoint list. The connection string might not be valid” as shown the image below.

I have checked all the possibilities for the error by changing the credentials in the report. It didn’t worked for me. Changed the connection string URL. Restarted BI development studio and Restarted Reporting services and finally restarted the machine too... No luck. L
By checking more than half day I have found the cause. The reason is, I have changed my VPN password recently and disabled UAC in my machine. So by connection the site, it is using my old password stored in windows vault.

We have to change the stored credentials in windows vault by using the steps below,
Navigate to Windows vault and in Windows credentials section select the site and update the credentials.

Now Iam able to access the list from SharePoint list  

Saturday, July 5, 2014

PowerShell Commands: Download files/documents from SharePoint document libraries

In SharePoint 2013 we have an option to sync all the data from SharePoint document libraries to local folders by using Shared drive concept. We can download the document s from SharePoint document library using Power Shell commands also. We can do that in overall site collections and all the site collection may contain loads of documents and downloading one by one is a huge task by using windows explorer.

To download the document we can use following script,

$listUrls="Doc lib 1 URL″,” Doc lib 2 URL ″,” Doc lib 3 URL ″," Doc lib 4 URL ″ (All the document libraries URL’s)
#Enter the web site URL

$web = Get-SPWeb -Identity $webUrl

#Load all the list URLs in the web, Open the list URL.

foreach($listUrl in $listUrls)

#get the list URL

$list = $web.GetList($webUrl+”/”+$listUrl)

function DownloadDocuments{
    $folder = $web.GetFolder($folderUrl)
    foreach ($file in $folder.Files) {

#Ensure destination directory

        $destinationfolder = $destination + “/” + $folder.Url
        if (!(Test-Path -path $destinationfolder))
            $dest = New-Item $destinationfolder -type directory

#Download file

        $binary = $file.OpenBinary()
        $stream = New-Object System.IO.FileStream($destinationfolder + “/” + $file.Name)
        $writer = New-Object System.IO.BinaryWriter($stream)

#Download root folder documents

DownloadDocuments ($list.RootFolder.Url)
foreach ($folder in $list.Folders) {

#download all the documents in each sub folders