Tuesday, March 15, 2016

SharePoint 2016 RTM is Released!

So the waiting period is over! SharePoint 2016 is in its RTM now!
sharepoint 2016 RTM download

Download SharePoint 2016 RTM Trial from here: https://www.microsoft.com/en-us/download/details.aspx?id=51493

180 day Trial key: NQGJR-63HC8-XCRQH-MYVCH-3J3QR

What's New: Fast Site Collection Creation, Durable Links, Hybrid Features, MinRoles, Large File support, etc.

What's Lost: No more SharePoint Foundation, No Stand-alone Install Mode (with SQL Express), No FIM, etc.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Sunday, March 13, 2016

The Database name located at the specified database server contains user-defined data.- Error in SharePoint Products Configuration Wizard

Error:
SharePoint Products Configuration Wizard:  
The Database name located at the specified database server contains user-defined data. Databases must be empty before they can be used. Delete all of the tables, stored procedures, and other objects, or use a different database.
The Database name located at the specified database server contains user-defined data

Root cause:
This is due to the fact, previous installation failed in between and left the SharePoint_Config database in SQL Server!

Solution:
Delete the SharePoint_Config database created by the previous installation!


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Wednesday, March 9, 2016

SharePoint Online: Export List Items to CSV using PowerShell

Requirement: 
Export SharePoint online list items to CSV file from client side.

PowerShell script to Export SharePoint List Items to CSV from Client Side (CSOM):
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
 
##Variables for Processing
$SiteUrl = "https://crescent.sharepoint.com/sites/poc/"
$ListName="Employee"
$ExportFile ="c:\Scripts\ListRpt.csv"
$UserName="Salaudeen@crescent.com"
$Password ="Password goes here"

#Setup Credentials to connect
$Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName,(ConvertTo-SecureString $Password -AsPlainText -Force))

#Set up the context
$Context = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl) 
$Context.Credentials = $credentials
 
#Get the List
$List = $Context.web.Lists.GetByTitle($ListName)

#Get All List Items
$Query = New-Object Microsoft.SharePoint.Client.CamlQuery
$ListItems = $List.GetItems($Query)
$context.Load($ListItems)
$context.ExecuteQuery()

#Array to Hold List Items 
$ListItemCollection = @() 

#Fetch each list item value to export to excel
 $ListItems |  foreach {
    $ExportItem = New-Object PSObject 
    $ExportItem | Add-Member -MemberType NoteProperty -name "Title" -value $_["Title"]
    $ExportItem | Add-Member -MemberType NoteProperty -Name "Department" -value $_["Department"]
  
    #Add the object with above properties to the Array
    $ListItemCollection += $ExportItem
 }
#Export the result Array to CSV file
$ListItemCollection | Export-CSV $ExportFile -NoTypeInformation 

Write-host "List data Exported to CSV file successfully!"

Related Posts:


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


Wednesday, March 2, 2016

Copy Files Between Document Libraries in SharePoint using PowerShell

Here is my PowerShell script to copy files between SharePoint document libraries:

PowerShell Script to Copy a File from One Library to Another:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables for Processing
$WebURL="https://portal.crescent.com/sites/Sales/"
$SourceFile="https://portal.crescent.com/sites/Sales/TeamDocs/InvoiceTemp.xlsx"
$TargetLibrary="Invoice Documents"

#Get Objects
$Web = Get-SPWeb $WebURL
$SourceFile = $Web.GetFile($SourceFile)
$TargetLibrary = $Web.GetFolder($TargetLibrary)

#Copy the file into the Target library
$File = $TargetLibrary.Files.Add($SourceFile.Name, $SourceFile.OpenBinary(), $true)

#Copy Meta-Data
$Item = $File.Item
$item["Created"] = $SourceFile.TimeCreated.ToLocalTime()
$item["Modified"] = $SourceFile.TimeLastModified.ToLocalTime()
$item["Author"] = $SourceFile.Author
$item["Editor"] = $SourceFile.ModifiedBy
#Update
$Item.UpdateOverwriteVersion()

PowerShell Script to Copy All Files Between Document Libraries:
Lets copy all files and folder from one library to another along with their meta-data (Excluding: the above!)
sAdd-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Custom Function to Copy Files from Source Folder to Target
Function Copy-Files($SourceFolder, $TargetFolder)
{
    write-host "Copying Files from:$($SourceFolder.URL) to $($TargetFolder.URL)"
    #Get Each File from the Source 
    $SourceFilesColl = $SourceFolder.Files

    #Iterate through each item from the source
    Foreach($SourceFile in $SourceFilesColl) 
    {
        #Copy File from the Source
        $NewFile = $TargetFolder.Files.Add($SourceFile.Name, $SourceFile.OpenBinary(),$True)
 
        #Copy Meta-Data from Source
        Foreach($Field in $SourceFile.Item.Fields)
        {
            If(!$Field.ReadOnlyField)
            {
                if($NewFile.Item.Fields.ContainsField($Field.InternalName))
                {
                    $NewFile.Item[$Field.InternalName] = $SourceFile.Item[$Field.InternalName]
                }
            }
        }
        #Update
        $NewFile.Item.UpdateOverwriteVersion()
    
        Write-host "Copied File:"$SourceFile.Name
    }
    
    #Process SubFolders
    Foreach($SubFolder in $SourceFolder.SubFolders)
    {
        if($SubFolder.Name -ne "Forms")
        {
            #Check if Sub-Folder exists in the Target Library!
            $NewTargetFolder = $TargetFolder.ParentWeb.GetFolder($SubFolder.Name)
 
            if ($NewTargetFolder.Exists -eq $false)
            {
                #Create a Folder
                $NewTargetFolder = $TargetFolder.SubFolders.Add($SubFolder.Name)
            }
            #Call the function recursively
            Copy-Files $SubFolder $NewTargetFolder
        }
    }
}

#Variables for Processing
$WebURL="http://portal.crescent.com/sites/sales/"
$SourceLibrary ="Team Docs"
$TargetLibrary = "Sales Documents"

#Get Objects
$Web = Get-SPWeb $WebURL
$SourceFolder = $Web.GetFolder($SourceLibrary)
$TargetFolder = $Web.GetFolder($TargetLibrary)

#Call the Function to Copy All Files
Copy-Files $SourceFolder $TargetFolder

Copy Documents between Sites, Site Collections, Web Applications:
How about copying between Sites? Well, just change the below lines in the script.
#Variables for Processing
$SourceWeb = "http://Your-Source-Web-URL"
$TargetWeb = "http://Your-Target-Web-URL"

$SourceLibrary ="Team Docs"
$TargetLibrary = "Shared Documents"

$SourceFolder = $Source.GetFolder($SourceLibrary)
$TargetFolder = $TargetWeb.GetFolder($TargetLibrary)

#Call the Function to Copy All Files
Copy-Files $SourceFolder $TargetFolder


You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.
*Sponsored


You might also like:

Related Posts Plugin for WordPress, Blogger...