Posts

Showing posts from April, 2014

Sharepoint 2010 Create External List using Powershell

SharePoint 2010 has introduced a new type of List called External List.  The External List is used for displaying content that comes from Business Connectivity Services (BCS) Enterprise content types.  Business Connectivity Services is the replacement in SharePoint 2010 for The Business Data Catalog (BDC) in SharePoint 2007.  External List needs External Content type for creating itself.  External Content Type is created using either SharePoint Designer 2010 or Visual Studio 2010.  Once the External Content Type is created, you can create the external list either from the Create page in SharePoint or via SharePoint Designer or Powershell.  Here is an example to create External List Using Powershell. clear   Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue   Add-PSSnapin Microsoft.SharePoint.Powershell $SiteUrl = " Site Url "   $BusinessListName = " BusinessList " $ConfigListName = "Config" $spweb = Get-SPWeb $SiteUrl $List

Powershell How to Use Dictionary/Hash Table

Image
Dictionary/Hash Table is a "Key, Value" pair. It can make a list of key and value. So its very easy to relate which key belongs to which value. Below is the example of hash table. clear Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue Add-PSSnapin Microsoft.SharePoint.Powershell  $SiteUrl = "http://pps-dd-lite:9595/Sites/IPM" $LobSystemInstance = "IPM.BCS.ReferenceDataInstance" $EntityNamespace = "IPM.BCS.ReferenceData" $myHash = @{} $myHash[" Key_1 "] = " Value_1_ABC " $myHash[" Key_2 "] = " Value_2_DEF " $myHash[" Key_3 "] = " Value_3_GHI "  foreach($key in $($myHash.keys)) {  Write-Host "For key"  $key  " value is "  $myHash[$key] }   Result:

Sharepoint 2010 Create Custom Site Column and Add to Content Type using Powershell

Sometimes we need to add column to existing content type. For the same there are two ways. one is delete content type. If it has used some where else than first need to delete that target and after that delete this content type and create from scratch. So its a very long process.  Another way is create a site column first and add that column to content type(Using Powershell) as below. It will help you for sure. clear Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue Add-PSSnapin Microsoft.SharePoint.Powershell Function AddFieldToContentType($web, $ctype, $fieldName, $DisplayName) {     $ct = $web.ContentTypes[$ctype]     $fieldXMLString = '<Field Type="Text"     Name= "'+$fieldName+'"     DisplayName= "'+$DisplayName+'"     Group="IPM Document Group"     Required="FALSE"     ShowInDisplayForm="TRUE"     ShowInEditForm="TRUE"     ShowInListSetti

Sharepoint 2010 Grant Permission to a Group using Powershell

Sometimes we need to grant permission to a particular group. There are different different permission levels in sharepoint. Below are some examples: Full Control,  Design, Contribute, Read, View Only For allow group of user as per mentioned permission level here is a powershell script. I think this will be very helpful for grant permissions. clear   Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue   Add-PSSnapin Microsoft.SharePoint.Powershell  $Url = " Sitecollection/Site Url on which we need to grant permissions " $GroupName = " All Authenticated Users "   #Group Name $PermissionLevel = " Full Control "  # Permission Level $Description = " This group contains all authenticated users. "               $web = Get-SPWeb -Identity $Url if ($web.SiteGroups[$GroupName] -ne $null) { Write-Host "Group $GroupName already exists!" -foregroundcolor Red } else { $web.SiteGroups.Ad