Powershell script – Get all Site Columns for a SharePoint 2013 site collection

Here is the power shell script to retrieve all Site Columns for a SharePoint 2013 or SharePoint 2010 site collection and generate the CSV file in Same working directory with the Name “Site Column Details.csv ” 

MSDN Tech Blog Link you can find here :

https://code.msdn.microsoft.com/Powershell-script-Get-all-8501c19d

Add-PsSnapin Microsoft.SharePoint.PowerShell 
## SharePoint DLL++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++Start 
[void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")  
 
# Give Your Site Collection URL 
 
$url"http://ptcpasaspapp03/sc1/" 
 
# Code to Get the current working directory and generate the file Name with Current Date and Time + SiteColumnDetails.CSV 
function Get-ScriptDirectory 
{ 
    $Invocation = (Get-Variable MyInvocation -Scope 1).Value 
    Split-Path $Invocation.MyCommand.Path 
}  
$localFolderObject = Get-ScriptDirectory 
$localFolder = $localFolderObject.ToString() + "\" 
#Get current working directory 
$today = Get-Date 
$fileName = $localFolder + $today.Day.ToString() + "-" + $today.month.ToString() + "-" + $today.year.ToString() + "--SiteColumnDetails.csv" 
 
 
#Writing the CSV Column Header  - Tab Separated 
 "Column Title `t Site Column ID `t InternalName `t StaticName `t MaxLength `t Description `t Group `t TypeShortDescription " | out-file $fileName 
 
 
#Operation+++++++++++++++++++++++++++++++++++++++++++++++++++Start 
$site   =    new-object Microsoft.SharePoint.SPSite($url$web    = $site.rootweb.Fields 
echo "Generating File..." 
ForEach ($id in $web) 
{ 
 
"$($id.Title) `t $($id.Id) `t $($id.InternalName) `t $($id.StaticName) `t $($id.MaxLength)/$($id.MaxLength) `t $($id.Description) `t $($id.Group) `t $($id.TypeShortDescription) " | Out-File $fileName -Append 
 
} 
$site.Dispose() 
 
#Operation+++++++++++++++++++++++++++++++++++++++++++++++++++Start 
echo "CSV file generated successfully, please check the below given path" 
echo "File created at : + $fileName "

About Krishana Kumar

Krishana Kumar is SharePoint Architect/Trainer having Architecture experience with high volumes at Enterprise level and global scale - creation of highly scalable solutions with global user base and geographically distributed architectural components. Good knowledge of SharePoint best practices and governance models. I hold Two Master degree in Computer Science with over 11 years of experience working on Microsoft Technologies specially SharePoint, Project, .NET and other Information Worker Technologies. Having good exposer in Client side scripting Angular.js, backbone and Node. I am currently responsible for SharePoint Infrastructure set up and leading teams in various medium and large scale projects, architecting, designing & installing SharePoint farms, developing custom components,, and providing advanced SharePoint administration and development training to teams and customers. I regularly speaks in various SharePoint User Groups and other Events. I have MCSA Windows Azure, MCSA Office 365, MCSE & MCSD SharePoint 2013, Microsoft Certified Developer (MCD) and holds MCPD, MCTIP and MCTS for SharePoint 2010, MCTS MOSS 2007 & WSS 3.0, MCPD, MCITP (EPM 2010 & 2007) and MCSD .NET.
This entry was posted in General Interest. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *