Search This Blog

Thursday, 23 April 2015

Web parts - An Introduction

What is a Web Part?


  • To users, a Web Part is simply a piece of a webpage that they can customize from a web browser interface. For example, users can even add and remove Web Parts from pages (often called Web Part pages) by choosing Web Parts from a server gallery or from an online public gallery.
  • For developers, a Web Part is a class that defines code for rendering its content in the browser, for handling custom configuration, layout, positioning, and so on, within the SharePoint or ASP.NET environment. More importantly, developers can reuse Web Parts in many different pages and sites, simplifying custom solution development, deployment, and maintenance. In fact, many SharePoint solutions are based on a set of custom Web Parts that are referenced in pages.
  • Web Part architecture

  • A Web Part is an ASP.NET custom control that inherits from the base class WebPart from the System.Web.UI.WebControls.WebParts namespace. To be able to fully use a Web Part in a page, you need to define a WebPartZone control, which is a container for a set of Web Parts. The WebPartZone control provides a common rendering pattern to all its constituent Web Parts. Another fundamental control in the Web Parts architecture is the WebPartManager, which handles all the tasks related to Web Part lifetime management—such as loading and unloading them, as well as serializing and deserializing their state within the current page and connecting Web Parts into Web Part zones.
  • SharePoint has its own WebPartZone controls that give you the ability to define a set of SharePoint-specific rendering zones, such as the WebPartZone class for standard Web Part rendering and the EditorZone class to render parts responsible for editing other Web Parts.

    Overall architecture of a Web Part page in SharePoint and ASP.NET

    Wednesday, 22 April 2015

    Hide Top Bar, Ribbon, Quick Launch in SharePoint

    •  Create a CSS file named (for example) Sample.css in the Style Library as follows
    <style type="text/css">
    /* Resizes to 0 the upper margin of the main area */
    .ms-pagetitleareaframe table { background: none; }
    /* Hides the left navigation area (quick launch bar) */
    #s4-leftpanel-content { display:none !important; }
    /* Resizes to 0 the left margin */
    .s4-ca { margin-left:0px !important; margin-right:0px !important; }
    /* Hides title and breadcrumb bar */
    .s4-title { display:none !important; }
    /* Hides the top navigation links */   
    .s4-tn { display:none !important; }
    /* Hides the top navigation container bar */
    .s4-notdlg { display:none !important; }
    /* Hides the search box */
    #SRSB { display:none !important; }
    /* Hides the help button */   
    .s4-help { visibility: hidden; }
    /* Hides user name in the top right corner and the related menu */   
    .s4-trc-container-menu { visibility: hidden; }
    /* Hides the ribbon */
    .ms-cui-ribbonTopBars{ display:none; }  body #s4-ribbonrow { min-height: 0 !important; display:none !important; }
    </style>
    • link the CSS file in the desired master page by adding this line:
    <link href="/Style%20Library/Sample.css" rel="stylesheet" type="text/css" />
    just above this line: <asp:ContentPlaceHolder id="PlaceHolderAdditionalPageHead" runat="server"/>

    Powershell - List all site level users with User Groups name

    #Input:-
    #1. Pass site URL as input
    #2. Pass output file path with file name and extension as "CSV"

    #Code:-
    $destWebappUrl= Read-Host "Enter site URL (Eg: http://<HostName>:8080/ )"
    $LogFilePath =  Read-Host "Enter Log file path (C:\.....\Log.csv)"

    # =========================== LOADING SHAREPOINT POWERSHELL SNAPIN FILE DETAILS =====================================
    $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
    if ($snapin -eq $null)
    {
                    Write-Host "Loading SharePoint Powershell Snapin" -ForegroundColor Green
                    $snapin = Add-PSSnapin "Microsoft.Sharepoint.Powershell"
                    Write-Host $snapin
    }

    $site = Get-SPSite $destWebappUrl

    Function GetUsersFromUserGroups
    {
        $groups = $site.RootWeb.sitegroups
        foreach ($grp in $groups)
        {
            $groupName= $grp.name;
            foreach ($user in $grp.users)
            {
                $userName= $user.name
                $msg = "$groupName,$userName"  |  Out-File $LogFilePath -append
            }
        }
        $site.Dispose()
    }

    [Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges(
    {
        Write-Host "Process Started...Time - $(get-date -format HH:mm:ss)" -Foregroundcolor Yellow
     
        $StartTime=Get-Date
        $msg = "User Group Name, User Name"  |  Out-File $LogFilePath -append          
        Write-Host "Processing..."
        GetUsersFromUserGroups
     
        $StartTime=(Get-Date) - $StartTime
        write-host "Total execution time- " $StartTime
        Write-Host "Process Completed...Time - $(get-date -format HH:mm:ss)" -Foregroundcolor Yellow

    })

    Powershell - Create a new Search Service Application in SharePoint 2013

    Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

    # Settings
    $IndexLocation = Read-Host "Enter Index location eg: C:\Data\Search15Index” #Location must be empty, will be deleted during the process!
    $SearchAppPoolName = Read-Host "Enter search Application pool name eg:Search App Pool"
    $SearchAppPoolAccountName = Read-Host "Enter search Application pool Account name eg:corp\username"
    $SearchServerName = (Get-ChildItem env:computername).value
    $SearchServiceName = Read-Host "Enter search Service name eg: Search15"
    $SearchServiceProxyName = Read-Host "Enter search Service proxy name eg: Search15 Proxy"
    $DatabaseName = Read-Host "Enter Database name eg: Search15_ADminDB"
    Write-Host -ForegroundColor Yellow "Checking if Search Application Pool exists"
    $SPAppPool = Get-SPServiceApplicationPool -Identity $SearchAppPoolName -ErrorAction SilentlyContinue

    if (!$SPAppPool)
    {
        Write-Host -ForegroundColor Green "Creating Search Application Pool"
        $spAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccountName -Verbose
    }

    # Start Services search service instance
    Write-host "Start Search Service instances...."
    Start-SPEnterpriseSearchServiceInstance $SearchServerName -ErrorAction SilentlyContinue
    Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $SearchServerName -ErrorAction SilentlyContinue

    Write-Host -ForegroundColor Yellow "Checking if Search Service Application exists"
    $ServiceApplication = Get-SPEnterpriseSearchServiceApplication -Identity $SearchServiceName -ErrorAction SilentlyContinue

    if (!$ServiceApplication)
    {
        Write-Host -ForegroundColor Green "Creating Search Service Application"
        $ServiceApplication = New-SPEnterpriseSearchServiceApplication -Partitioned -Name $SearchServiceName -ApplicationPool $spAppPool.Name
    -DatabaseName $DatabaseName
    }

    Write-Host -ForegroundColor Yellow "Checking if Search Service Application Proxy exists"
    $Proxy = Get-SPEnterpriseSearchServiceApplicationProxy -Identity $SearchServiceProxyName -ErrorAction SilentlyContinue

    if (!$Proxy)
    {
        Write-Host -ForegroundColor Green "Creating Search Service Application Proxy"
        New-SPEnterpriseSearchServiceApplicationProxy -Partitioned -Name $SearchServiceProxyName -SearchApplication $ServiceApplication
    }


    $ServiceApplication.ActiveTopology
    Write-Host $ServiceApplication.ActiveTopology

    # Clone the default Topology (which is empty) and create a new one and then activate it
    Write-Host "Configuring Search Component Topology...."
    $clone = $ServiceApplication.ActiveTopology.Clone()
    $SSI = Get-SPEnterpriseSearchServiceInstance -local
    New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $SSI
    New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $SSI
    New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $SSI
    New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $SSI

    Remove-Item -Recurse -Force -LiteralPath $IndexLocation -ErrorAction SilentlyContinue
    mkdir -Path $IndexLocation -Force

    New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $SSI -RootDirectory $IndexLocation
    New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $SSI
    $clone.Activate()

    Write-host "Your search service application $SearchServiceName is now ready"

    Powershell - Creating a Document Library

    cls
    Remove-PSSnapin Microsoft.SharePoint.Powershell -ErrorAction SilentlyContinue
    Add-PSSnapin Microsoft.SharePoint.Powershell

    # varable description
    $webUrl = Read-Host "Enter site URL (Eg: http://<HostName>:1111/sites/sitecollname )"
    $web = Get-SPWeb $webUrl
    $libraryName = Read-Host "Enter Library Name"
    $libraryDescription = Read-Host "Enter description"
    $libraryTemplate = [Microsoft.SharePoint.SPListTemplateType]::DocumentLibrary;

    # Adding Library
    try
    {
        $web.Lists.Add($libraryName,$libraryDescription,$libraryTemplate);
        $web.Update();
    }
    catch
    {
        write-host "Error" $_.exception
        $errorlabel = $true
    }

    finally
    {
    if($web -ne $null)
    {
    $web.Dispose()
    }
    }

    Poweshell - Create Sites From CSV

    <#
    .SYNOPSIS
       <A brief description of the script>
    .DESCRIPTION
       <A detailed description of the script>
    .PARAMETER <paramName>
       <Description of script parameter>
    .EXAMPLE
       <An example of using the script>
    #>


    $UrlWebApp = Read-Host "Enter site URL (Eg: http://<HostName>:1111/sites/sitecollname )"
    $global:strGroupListFileName = Read-Host "Enter the location of Sites.csv"
    $LogPath = Read-Host "Enter a location for log file  :"
    $LogFileName = Read-Host "Enter name for log file  :"
    $FilePath = $LogPath + "\" + $LogFileName


    # =========================== LOADING SHAREPOITN POWERSHELL SNAPIN FILE DETAILS =====================================
    #Loading Snap in for Microsoft.Sharepoint.Powershell
    $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}

    if ($snapin -eq $null)
    {
    Write-Host "Loading SharePoint Powershell Snapin" -ForegroundColor Green
    $snapin = Add-PSSnapin "Microsoft.Sharepoint.Powershell"

    Write-Host $snapin
    }
    # =============================================================================

    #=========================== SharePoint DLL ==========================
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")



    function write-log([string]$label, [string]$logMsg)
    {
        if($logFileCreated -eq $False)
        {
            write-host "Creating log file..."
            if((Test-Path -path $LogPath) -ne $True)
            {
                write-host "Provide proper values to LogPath folder" -ForegroundColor Red
            }
            else
            {
                Add-Content -Path $FilePath -Value $logHeader
                $script:logFileCreated  = $True
                write-host "Log file created..."
            }
        }
        else
        {
            [string]$info = [System.String]::Format("[$Date] {0}: {1}",$label, $logMsg)
            Add-Content -Path $FilePath -Value $info
        }
    }

    function createSubsite($parentSiteCollectionUrl,$SubsiteName,$TemplatePath)
    {
    $IssubsiteCreated = $false;
    $SubsiteUrl ="$parentSiteCollectionUrl/$SubsiteName";
    $ParentWeb = Get-SPWeb $parentSiteCollectionUrl
    $SubWeb = Get-SPWeb $SubsiteUrl -ErrorAction SilentlyContinue -ErrorVariable err
    try
    {
    if(([string]$err).Length -ne 0)
    {
    $SubWeb = New-SPWeb $SubsiteUrl -Description "A site created by ps" -ErrorAction SilentlyContinue -ErrorVariable err -name $SubsiteName
    $WebTemplate = $ParentWeb.GetAvailableWebTemplates($ParentWeb.language) | Where-Object {$_.Title -eq $TemplatePath};
    $SubWeb.ApplyWebTemplate($WebTemplate.Name) | out-null
    return $SubWeb.Url;
    }
    else
    {
    Write-Host $err -ForegroundColor RED
    return $SubWeb.Url;
    }
    return $SubWeb.Url;
    }
    finally
    {
    if($SubWeb -ne $null)
    {
    $SubWeb.Close();
    }
    if($ParentWeb -ne $null)
    {
    $ParentWeb.Close();
    }
    }
    }

    [Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges(
    {
                    Write-Host "Create Process Started...Time - $(get-date -format HH:mm:ss)" -Foregroundcolor Green
                    write-log  "Create Process Started...Time -" "$(get-date -format HH:mm:ss)"
                    $StartTime=Get-Date

    $site = Get-SPSite $UrlWebApp
    $SiteCollectionUrl = $Site.Url;
    $PathDealSiteTemplate = "STS#0"
           if($site -ne $null)
    {
                      $siteUrl = $Site.Url;
     Import-CSV -Path $global:strGroupListFileName   | ForEach-Object {
                        if($_.SiteName -ne $null -and $_.SiteName -ne "")
                         {
    $SiteName=$_.SiteName
                        createSubsite $SiteCollectionUrl $SiteName $PathDealSiteTemplate
                            Write-Host "Site created for Asset $SiteName";
                            Write-Log "Site created for Asset $SiteName";
       
                           }
    }                  
            }
        $StartTime=(Get-Date) - $StartTime
          write-host "Total execution time- " $StartTime
          write-log "Total execution time- " $StartTime
          Write-Host "Create Process Completed...Time - $(get-date -format HH:mm:ss)" -Foregroundcolor Green
          write-log "Create Process Completed...Time -" "$(get-date -format HH:mm:ss)"                    
    })

    SharePoint basic concepts - 3

    Sharepoint History:

    Year
    Free Version
    Paid Version
    Remarks
    2001
    SharePoint Team Services
    SharePoint Portal Server2001
    CMS(failure due to heavy cost) everything is paid version only
    2003
    wss2.0
    SharePoint Portal Server2003
    CMS*(better in 2003 because reduces cost and give some features free)
    2007
    wss3.0
    Microsoft office SharePoint server
    CMS+WCM*( ultimate version and most popular and MS office give free)
    2010
    SharePoint Foundation 
    SharePoint Server2010
    CMS+WCM+ECMS*( rich applications + new and advanced features)
    2013
    SharePoint Foundation +
    SharePoint Server2013
    CMS+WCM+ECMS*+ new advanced feature+apps
    Windows Sharepoint Services (WSS)
    Windows Sharepoint  Services (WSS) is a portal-based platform for creating, managing and sharing documents and customized Web services. WSS is available as a free download included with every Windows Server license and is considered to be part of the Office 2003 productivity suite. 
    Content management system (CMS):
    • CMS    is a computer program that allows publishingediting and modifying content as well as maintenance from a central interface Such systems of content provide procedures to manage workflow in a collaborative environment.
    • CMS  is a more complex and powerful functions
    • CMSs are often used to run websites containing blogs, news, and shopping. Many corporate and marketing websites use CMSs. 
    3 types of CMS
    1. Web content management system(WCM)
    2. Component content management system
    3. Enterprise content management systems(ECMS)
    Enterprise content management types:
    Web content management:
    Web content management capabilities to create, publish, manage, and control a large, dynamic collection of content. Web content management, as part of Enterprise Content Management (ECM) in Office SharePoint Server 2007, can help streamline your process for creating and publishing Web sites.
    Document content mgmt system:
    Document management  capabilities on the storage and organization of documents to support active work in progress, including content creation and sharing within an organization
    Microsoft Office SharePoint Server 2007 supports your organization's document management needs by providing a broad set of document management capabilities that enable you to do the following.
    ->Store, organize, and locate documents.
    ->Ensure the consistency of documents.
    ->Manage metadata for documents.
    ->Help protect documents from unauthorized access or use.
    ->Ensure consistent business processes (workflows) for how documents are handled.

    Powershell - Create UserGroups from csv

    <#
    .SYNOPSIS
       <A brief description of the script>
    .DESCRIPTION
       <A detailed description of the script>
    .PARAMETER <paramName>
       <Description of script parameter>
    .EXAMPLE
       <An example of using the script>
    #>

    $UrlSite = Read-Host "Enter destination web app url"
    $global:strGroupListFileName = Read-Host "Enter the location of Groups.csv"
    $LogPath = Read-Host "Enter a location for log file  :"
    $LogFileName = Read-Host "Enter name for log file  :"
    $FilePath = $LogPath + "\" + $LogFileName

    # =========================== LOADING SHAREPOITN POWERSHELL SNAPIN FILE DETAILS =====================================
    #Loading Snap in for Microsoft.Sharepoint.Powershell

    $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}

    if ($snapin -eq $null)
    {
    Write-Host "Loading SharePoint Powershell Snapin" -ForegroundColor Green
    $snapin = Add-PSSnapin "Microsoft.Sharepoint.Powershell" -ErrorAction SilentlyContinue

    Write-Host $snapin
    }
    # =============================================================================

    #=========================== SharePoint DLL ==========================
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint")
    [void][System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint.Publishing")



    function write-log([string]$label, [string]$logMsg)
    {
        if($logFileCreated -eq $False)
        {
            write-host "Creating log file..."
            if((Test-Path -path $LogPath) -ne $True)
            {
                write-host "Provide proper values to LogPath folder" -ForegroundColor Red
            }
            else
            {
                Add-Content -Path $FilePath -Value $logHeader
                $script:logFileCreated  = $True
                write-host "Log file created..."
            }
        }
        else
        {
            [string]$info = [System.String]::Format("[$Date] {0}: {1}",$label, $logMsg)
            Add-Content -Path $FilePath -Value $info
        }
    }

    function AddGroup
    {
    $web = get-SPWeb  $global:SiteName
    $GroupName =$global:Group
    if ($web.SiteGroups[$GroupName] -ne $null){

    Write-Host "Group already exists!"
    Break
    }
    else
    {
        $web.SiteGroups.Add($GroupName, $web.Site.Owner, $web.Site.Owner, "Use this group to grant people read permissions to the $web site")
        $group = $web.SiteGroups[$GroupName]
        $roleAssignment = new-object Microsoft.SharePoint.SPRoleAssignment($group)
        $roleDefinition = $web.Site.RootWeb.RoleDefinitions["Read"]
        $roleAssignment.RoleDefinitionBindings.Add($roleDefinition)
        $web.RoleAssignments.Add($roleAssignment)
        write-log "Group Added"
        write-host "Group Added"

    }

    }

    [Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges(
    {
                    Write-Host "Addition Process Started...Time - $(get-date -format HH:mm:ss)" -Foregroundcolor Green
                    write-log  "Addition Process Started...Time -" "$(get-date -format HH:mm:ss)"
                    $StartTime=Get-Date
                        $Site = Get-SPSite $UrlSite
                $siteUrl = $Site.Url;
                       
                $web=$site.RootWeb
                        $webUrl = $web.Url
            try
            {
                           
            Import-CSV -Path $global:strGroupListFileName   | ForEach-Object {
                           
                                            if($_.UserGroup -ne $null -and $_.UserGroup -ne "")
                                            {
                                                $global:SiteName = $webUrl
                                                $global:Group=$_.UserGroup
                                                write-log "Site Group"
                                                write-log $global:Group  
                                                write-host "Site Group"
                                                write-host $global:Group                                          
                                                AddGroup
                                               
                                            }
                                       }
                                       $web.update();
            }
            finally
            {
            #$web.Dispose();
            }
               
    })

    Powershell - Create Terms from csv

    # =========================== Central Admin Details =====================================
    $centralAdminUrl= Read-Host "Enter Central Admin URL (Eg: http://<HostName>:8080 )"



    $snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.Powershell'}
    if ($snapin -eq $null)
    {
        Write-Host "Loading SharePoint Powershell Snapin" -ForegroundColor Green
        $snapin = Add-PSSnapin "Microsoft.Sharepoint.Powershell"
        Write-Host $snapin
    }

    $global:strTermFileName = Read-Host "Enter the location of Terms.csv"
    $LogPath = Read-Host "Enter a location for log file  :"
    $LogFileName = Read-Host "Enter name for log file  :"
    $FilePath = $LogPath + "\" + $LogFileName

    # =========================== Managed Metadata Service Details =====================================

    $MMSApplicationName="Managed Metadata Service";
    $MMSGroupName= "abc ";
    $MMSTermSet="test1";
    #===================================================================================================

    function write-log([string]$label, [string]$logMsg)
    {
        if($logFileCreated -eq $False)
        {
            write-host "Creating log file..."
            if((Test-Path -path $LogPath) -ne $True)
            {
                write-host "Provide proper values to LogPath folder" -ForegroundColor Red
            }
            else
            {
                Add-Content -Path $FilePath -Value $logHeader
                $script:logFileCreated  = $True
                write-host "Log file created..."
            }
        }
        else
        {
            [string]$info = [System.String]::Format("[$Date] {0}: {1}",$label, $logMsg)
            Add-Content -Path $FilePath -Value $info
        }
    }


    [Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges(
    {
                    Write-Host "Term Creation Process Started...Time - $(get-date -format HH:mm:ss)" -Foregroundcolor Green
                    write-log  "Term Creation Process Started...Time -" "$(get-date -format HH:mm:ss)"
                    $StartTime=Get-Date
                   
                    Import-CSV -Path $global:strTermFileName   | ForEach-Object {
                                    if($_.TERM -ne $null -and $_.TERM -ne "")
                                    {
                                    $global:libraryTerm=$_.TERM                              
                                    Write-Host $global:libraryTerm
                                    write-log $global:libraryTerm
                                    #Connect to Central Admin
                                    $taxonomySite = get-SPSite $centralAdminUrl

                                        #Connect to Term Store in the Managed Metadata Service Application
                                        $taxonomySession = Get-SPTaxonomySession -site $taxonomySite
                                        $termStore = $taxonomySession.TermStores[$MMSApplicationName]
                                        write-host "Connection made with term store -"$termStore.Name

                                        #Connect to the Group and Term Set
                                        $termStoreGroup = $termStore.Groups[$MMSGroupName]
                                        $termSet = $termStoreGroup.TermSets[$MMSTermSet]
                                        $termCreate = $termSet.CreateTerm($global:libraryTerm, 1033)
                                        $termCreate.SetDescription("Term Description", 1033)
                                        $termCreate.CreateLabel($global:libraryTerm +" Category", 1033, $false)
                                        #Update the Term Store
                                        $termStore.CommitAll()
                                   
                                     }
                                   
                           }
                             $StartTime=(Get-Date) - $StartTime
                    write-host "Total execution time- " $StartTime
                    write-log "Total execution time- " $StartTime
                    Write-Host "Term Creation Process Completed...Time - $(get-date -format HH:mm:ss)" -Foregroundcolor Green
                    write-log "Term Creation Process Completed...Time -" "$(get-date -format HH:mm:ss)"
                    })


    #Note:- im getting Terms from csv file

    Powershell - Back up and Restore of Sitecollection

    # Back up site collection
    $UrlWebApp = Read-Host "Enter site URL to Backup "
    $location = Read-Host "Enter Location to backup (Eg:C:\SharePointBackups\Tutorials.bak)"

    backup-spsite -identity $UrlWebApp -path $location


    # Restore site collection

    #Restore-spsite -identity $UrlWebApp -path $location

    Powershell - Adding users to SPGroups

    if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)
    {
        Write-Host "Connect Sharepoint cmd-Let"
        Add-PSSnapin Microsoft.SharePoint.PowerShell
    }
    $url = Read-Host "Enter site URL (Eg: http://<HostName>:1111/sites/sitecollname )"
    $site = new-object Microsoft.SharePoint.SPSite($url)
    $web = $site.OpenWeb()
    $groups = $web.sitegroups

    $userName = Read-Host "Enter username"
    write-host "--------------"
    $i = 0;
    $myGroups = @();
    foreach($group in $groups) {
      if($group -match "admin") {
            $myGroups += $group
        }
    }

    foreach ($gr in $myGroups) {
        write-host $gr
    #add user to SP Group
        Set-SPUser -Identity $userName -web $url -Group $gr
        $theGroup = $web.SiteGroups[$gr]    
        $theUser = $web.AllUsers.Item($userName)

    #Remove user from SP Group
    #   $theGroup.RemoveUser($theUser);
        write-host "User " $userName   "added to " $gr
    }

    SharePoint basic concepts - 2

    Logical and physical architecture
    Whenever you deploy a SharePoint environment, in reality, you’re deploying a logical architecture called a SharePoint farm. A SharePoint farm is a set of servers that have different roles and offer various services that together make up a server farm suitable for hosting a full SharePoint deployment. Here are the common server roles in a SharePoint farm:


    • Front-end web servers These servers publish websites, often called web applications.



    • Application servers These servers host back-end services, such as Search services, the User Profile service, Excel Services, and so forth.



    • Database servers These servers store configuration and content data for the entire SharePoint farm.

    The smallest farm you can build is based on a single server; this type is often called the single server farm deployment. However, it is highly recommended that you avoid such a scenario, except for testing or development.

     Sharepoint Heirarchy

    SPFarm -> SPServer -> SPServices -   >SPWebServices  ->SPWebApplication  ->SPSite Collection
                                                    -> SPWeb  ->SPList  ->SPField  ->SPItem ->SPFile ->SPFolder




    A simplified schema of a sample SharePoint farm with an N-tier topology.





    Monday, 20 April 2015

    What is SharePoint?

    Microsoft often defines SharePoint as a business collaboration platform that makes it easier for
    people to work together. As a software developer, I prefer to define it as a platform with a rich framework for developing business solutions.
    From a developer’s perspective, 
    SharePoint is simply a rich set of tools, classes, libraries, controls, and so on, that are useful for building business solutions focused on collaboration, content management, social networking, content searches, and more.
    Many people think of SharePoint as a platform that’s ready to use for building websites—usually
    for intranet or extranet scenarios. That’s true, but it’s less than half the story! Certainly, SharePoint is a platform for building websites, and of course, it can target intranet and extranet sites.
    But it is much more, as well; you can use it to build any kind of web solution, including Internet publishing sites, by taking advantage of its well-defined and ready-to-use set of tools, based on a secure, scalable, and maintainable architecture. 
    You can think of SharePoint as a superset of Microsoft ASP.NET, with a
    broad set of services that can speed up the development of web-based collaborative solutions.
    You should use SharePoint as a shared connection point between users, customers, and whoever
    else uses your websites and the applications they utilize. The basic idea of SharePoint is to share content, applications, and data to improve collaboration and provide a unique user experience.
    SharePoint itself is primarily a container of content and apps. Content is organized in lists,
     and each list is made up of items. A list can consist of simple items with custom metadata properties called fields. Lists can also be libraries of documents, which are a particular kind of item that correspond to document files. Almost always when you develop a SharePoint solution, you manage lists and items.