Monday, August 21, 2017

How to lock a SharePoint site collection

By locking the SharePoint site collection, you can prevent it from updating contents or accessing contents. You would need this locking, when you migrate a SharePoint in to different version or in special case when a site collection is out of its storage limits.

Mainly, there 4 locking options are available.
  • Not Locked -   This is used to unlock the locked site collection.
  • Adding content prevented -   This is used to block the adding content but updating & deleting are allowed.
  • No access -   This is used to block the accessing contents of the site collection
  • Read-only -   This is used to block adding, updating & deleting contents but, accessing contents is allowed.

Furthermore you can lock a SharePoint site collection in 3 ways.
  1. By using SharePoint Central Administration
  2. By using SharePoint management shell

By using SharePoint Central Administration





By using SharePoint management shell

  1. First open the SharePoint Management shell as Administrator.
  2. Enter bellow shown command with relevant parameters and press ENTER.
         Set-SPSite -Identity "SiteCollection" -LockState "State"

Eg :- 
         Set-SPSite -Identity "http://SitecollectionName" -LockState "ReadOnly"

         Identity - It is the URL of the site collection, you are going to lock.
         LockState - This is the lock state.


Keep sharing the knowledge! :)

Thursday, November 3, 2016

How enable the disabled network adapter in Microsoft Azure virtual Machine

Once the network adapter is disabled in the Azure virtual machine, it is out of the network, so cannot be connected to the particular machine through the internet. Therefore connecting to the particular virtual machine is disabled since it is out of network. This happens due to the disabling the network adapter in Azure virtual machine.

This is not an issue of Azure, it happens due to the disabling of the network adapter. Even in a Windows PC, when the network adapter is disabled users cant connect to the machine, same thing happens here as well, but the difference is in a Windows PC we can log in and Enable the network adapter but in a Azure virtual machine it is not possible in order to logging to the machine it needs to be available in the network.

To sort this issue up, the administrator of Azure management portal has to follow bellow shown work out.

Step 1 : Administrator has to sign in to the Windows Azure management portal.

Step 2 : Navigate to the portal all virtual machines are listed by using left navigation.





















Step 3 : Select the virtual machine by clicking on it.














Step 4 : Click on the Configure option to navigate to the configuration portal of the particular machine.











Step 5 : Change the size of the virtual machine to something else by using below shown drop down.









Step 6 : Save the changes by clicking the Save button which is available at the bottom.

Now you should be allowed to connect to virtual machine by using remote desktop. After connecting to the virtual machine make sure the done virtual machine size change is reverted back to original size.


Keep sharing the knowledge! :)



Thursday, October 27, 2016

Updating a item in the SharePoint list using SharePoint management shell

In SharePoint there are number of field types are available. Those are Text, Choice, Number, Date, Yes/No, Hyperlink, Lookup and LookupMulti, Person or Group. According to the field type, the way of inserting will be different (different type of object should be assigned according to the field type).

As a first step the relevant item should be retrieved prior to the update.

$web = get-spweb "SiteCollection url"
$list = $web.lists | where {$_.title -eq "List Name"}
$item = $list.items | where {$_['Column Name'] -eq "Query Value"}

As the second step relevant type of objects should be set to the appropriate fields.Bellow shown SharePoint management shell script shows the way values are assigned to Text, Yes/No, Choice, Number, DateTime, Hyperlink, Person or Group, Lookup and LookupMulti type fields.

$item["Text"] = "Test Value"
$item["Yes/No"] = $true
$item["Choice"] = "MyChoice"
$item["Number"] = 10
$item["DateTime"] = Get-Date
$item["Hyperlink"] = "<a href="http://neranjanb1987.blogspot.com">My Blog</a>, Neranjan Bandara"

$spUser = get-spuser -Web "Url of the SiteCollection" -Identity "Login Name"
$item["PersonorGroup"] = $spUser

$lookup = New-Object Microsoft.Sharepoint.SPFieldLookupValue(1,"Service 1")
$item["Lookup"] = $lookup

$lookup1 = New-Object Microsoft.Sharepoint.SPFieldLookupValue(1,"Value 1")
$lookup2 = New-Object Microsoft.Sharepoint.SPFieldLookupValue(2,"Value 2")
$lookup3 = New-Object Microsoft.Sharepoint.SPFieldLookupValue(3,"Value 3")
$multiLookup = New-Object Microsoft.Sharepoint.SPFieldMultiChoiceValue($null)
$multiLookup.Add($lookup1)
$multiLookup.Add($lookup2)
$multiLookup.Add($lookup3)

$item["LookupMulti"] = $multiLookup

As the Final step item should be updated, after the item updating, the list also should be updated.

$item.update()
$list.update()

Now your item is updated properly, after the complection of the script check the item in the SharePoint list.


Keep sharing the knowledge! :)

Monday, October 17, 2016

Updating SharePoint Multi Select Lookup field and Multi Select Choice filed in SharePoint 2013 REST api

What is Multi Select Lookup field ?


A Multi select lookup column is a field in the SharePoint list whose values are retrieved from another List. Using a multi select lookup column, you can display a list of choices in a combo box or list box. Since the lookup column is multi select, you can choose more than one item in the list.

What is Multi Select Choice filed ?


A Multi select choice field in the SharePoint list is column type that is possible to have more than one choice at once.

Work around


In normal scenario when a Lookup field is updated, as we know item id of the lookup list should be saved against the lookup column, but when it comes to the Multi select lookup column it is different.

When the normal Choice filed is updated string choice should be saved against the choice column, but if it is a Multi select choice field, it is different.

By using blow shown rest endpoint, all the LookupMulti type columns in a particular SharePoint list can be retrieved.  

{site Url}/_api/web/lists/getbytitle('List Name')/fields?$filter=TypeAsString eq 'LookupMulti'

Please consider the result

1 Results for REST call

Bellow shown image shows the type of the field which is in JSON object.

2. Type of the column

Blow shown image shows a item which is retrieved using mentioned rest api call.

{site Url}/_api/web/lists/getbytitle('List Name')/items

As it shown in the bellow image, Multi select lookup field is contained a object. That object has two attributes metadata and results. metadata contained another object and result contained int array.

3. Retrieved result
Now we will see how we should update Multi select lookup field and Multi select choice field using REST api.

If the Multi select lookup field needs to be updated, below shown object should be saved against the multi select lookup column.

"result" should be a int array, which contains the item ids of the lookup list.


var lookUpMultiItemObj = {
                                                   __metadata: { "type": "Collection(Edm.Int32)" },
                                                   results: [1,3]
                                             };
listItem["Column Name"] = lookUpMultiItemObj
;

If the Multi select choice field needs to be updated, below shown object should be saved against the multi select choice column.

"result" should be a string array, which contains the choices of the field.


var choiceMultiItemObj = {
                                                   __metadata: { "type": "Collection(Edm.String)" },
                                                   results: ["Choice 2","Choice 4"]
    };
listItem["Column Name"] = choiceMultiItemObj;


4. Real code sample


After completing aforementioned steps, by using a normal ajax POST request the relevant items can be updated.


Keep sharing the knowledge! :) 





Monday, April 4, 2016

Set up the SharePoint Online Management Shell for SharePoint Online

What is SharePoint Online Management Shell ?

It is a Windows PowerShell module, that is to be used for managing Users, sites, organizations and site collections of SharePoint online.

How to Set up the SharePoint Online Management Shell for SharePoint Online ?

Step 01

Download SharePoint Online Management Shell from  here.

Step 02

Double click on that sharepointonlinemanagementshell program file and install it.

Step 04

Click Start>All Programs>SharePoint Online Management Shell to open it.



Step 03

Connect-SPOService -Url "Sitecollection" -Credential "User Name"

Copy above shown command and paste it in the SharePoint Online Management Shell then press Enter.

Url - Its the url of the particular administrator site of that particular site collection.

Eg-:

If the Url of the site this https://mst009.sharepoint.com, 

Credential - User Name which is needed to grant access to the admin site.

Eg -:


Once the command is entered, below shown dialog box will be popped up to provide the credentials to the particular account


 Once the correct credential is provided and the OK button clicked, it gives the below screen.



Now the configuration of SharePoint online power shell is succeeded, it can be checked by providing Get-SPOSite  command. It will list down all the site collections.

If you suppose to investigate about SharePoint Online Management Shell more, i recommend you to use this articular.


Keep sharing the knowledge! :) 

Monday, March 21, 2016

Basic Sectors of SharePoint Development


SharePoint contains huge number of technologies under SharePoint platform umbrella. According to the end user information in the industry, SharePoint is heavily used for document management, intranets, knowledge bases, web content management and business reporting tools.
According to the working experience of SharePoint development I would suggest that each and every SharePoint developer or beginner would pay attention to some basic as well as core sectors of SharePoint development. It would help to manage and understand SharePoint properly, furthermore it will assist you to gain more and more SharePoint knowledge based on that basic understanding. This would help you to come to a point that you can manage SharePoint properly.
As it is mentioned above, below shown sectors are the basic sectors of SharePoint development. This will help you to explore SharePoint through an appropriate path.

                        1.      SharePoint installation & configuration

This is the first sector, in order to use SharePoint it should be installed and configured properly according to the requirements.
·   Deciding the service applications which need to be provisioned according to the provided requirements.
·    Deciding the farm architecture (Whether the single farm, 2 tier farm or 3 tier farm architecture is used, but single tier farm is not recommended as the production environment)
·         Installation
1)      Windows (Windows should be installed in each and every server that are in the farm)
2)      SQL (SQL should be installed in each and every server which are in database layer)
3)      SharePoint (SharePoint should be installed in each and every server that are used in application server layer and web front end server layer)

·       Configuration (After the proper SharePoint, installation mandatory service applications and additional service applications should be created according to the requirement, furthermore in this installation users with proper permission level and proper application pools have to be used).


2.      Designing & development


When it comes to the designing phase design of the particular SharePoint solution should be aligned with best practices for best performance.
SharePoint development is normally divided in to two categories, developing solutions with SharePoint inbuilt features (no code solutions) and developing a custom solution by using visual studio, SharePoint designer, etc. In aforementioned custom solutions SharePoint object are accessed to fulfill operations. Ways of accessing SharePoint are listed below.

SSOM – It stands for Server Side Object Model and it allows to access SharePoint objects in server side.
CSOM (JSOM, REST api) – It stands for Client Side Object Model and it allows to access SharePoint object in client side.
Web services – SharePoint inbuilt web services allows to access SharePoint objects out of the SharePoint environment.
Below mentioned tools are widely used for custom developments.
·         Visual studio
·         SharePoint designer
Additionally, AngularJS is used as a framework that binds the HTML (View) to JavaScript objects (Model). 


                  3.      Branding

In this phase, mainly concerning about design and the usability of the SharePoint site. Below mentioned tools are widely used for branding
·         Photoshop
·         SharePoint Designer
Apart from that, SharePoint inbuilt features like device manger and device channel are used, moreover below mentioned technologies are used.
·         jQuery
·         Bootstrap
·         CSS3
·         HTML 5

4. Administration & troubleshooting

Administration is the way of managing and maintaining the SharePoint. In this case it mainly contains database administration, infrastructure administration, backup and recovery administration and disaster planning.
Mainly it needs the knowledge areas of networking, operating IIS, SQL, SharePoint central administration, STSADM and SharePoint PowerShell.
Apart from that, should have capability of managing services and scheduled jobs within the SharePoint environment, creating new sites and lists, installing new web parts, doing backups, managing the Shared Services, educating users on how to use features like InfoPath, managing governance policies and permissions.
Troubleshooting means, the ability to find and resolve the issues in SharePoint. Below mentioned tools are widely used to troubleshoot SharePoint.
·         ULS
·         Event Logs
·         SQL logs
·         Developer dashboard
·         Performance monitor
·         Health Analyzer
·         Fiddler


5. Migration and scaling out

SharePoint migration is the process of migrating the content of a SharePoint farm to another farm. The Upgrading refers to the process of converting the version of a SharePoint to a higher version (eg -: SharePoint 2010 to 2013)
In order to start SharePoint migration, a proper plan should be prepared for the particular migration. It should contained,
  • What should be migrated
  • How should be migrated
  • What are the important contents and where are those located
Basically three types of migration methods are used in the industry, those are listed below.
  • In-place migration
  • Database attached migration
  •  Using a well-supported third party tool

In SharePoint, “scaling out the farm” stands for adding one or more server roles to the existing farm. Web-front end servers, Application servers, database servers, search servers are the main server roles in SharePoint.
Web front end servers process incoming request by using IIS, request data from services and database, process received data and sending response to the request through a Asp.net page.
Application servers are the servers where the service applications are hosted.
Database servers contains all the databases which are dealing with SharePoint.
Search servers are the places where the search service application is hosted. This depends on the usage of the search service in the SharePoint farm. If the search service doesn’t need much resources and it is not used heavily, search service application can be hosted in application server as normal service applications.

                6.  Performance tuning

According to my working experiences SharePoint performance relies on many factors, but for easiness of understanding it can be divided below mentioned domains.
·         Windows server
1.      Windows server performance option
Computer>properties>Advanced system settings > Performance>Settings>visual effects   and select best performance option
2.      Page file size
Computer>properties>Advanced system settings> Performance>Settings>Advanced>virtual memory>settings
Page file size=RAM size * 1.5
3.      Use the Proper power plan
Start>Control Panel>Power Options > select the high performance
4.      Stop unused services
Spooler, AudioSrv, TabletLnputService, WerSvc services 
5.      Check Loopback
6.      Install latest and correct updates to the server.
7.      Define SQL rules on the firewall
8.      Exclude data, transaction and log files from real-time Antivirus scan.
9.      Put log and index files on separate disks

·         SQL
1.      Use dedicated server for sql, furthermore don’t use the default instant

<500GB data farm
500GB-1T
data farm
1T-2T
data farm
2T-5T
data farm
>5T
data farm
RAM
8
16
32
64
64+
CPU
4
4
8
8
8


2.      Check the disk and the NTFS allocation size of the particular drive.
Eg :- Use “chkdsk C:” for the drive and SQL has 64k

3.      Modify the model default database size to a maximum amount that is possible in the particular environment.
4.      Modify the auto growth of the model database, which is possible in the particular environment.
5.      Active back up compression
6.      Make Max degree of parallelism 1
7.      Exclude data files, transaction logs and back up files from Antivirus real time scanning.
·         SharePoint
1.      Try to avoid using the Product Configuration Wizard.
2.      20 web applications is maximum recommended for a share point farm.
3.      5000 site collections is maximum recommended for a Web application.
4.      Avoid “-Force” deployed as much as possible
5.  Avoid Global deployments (Scope) as much as possible unless or otherwise it’s needed.
·         IIS
1.      Wake up script

2.      Enabling BLOB cache in web config file.

 I hope this blog post provides the basic understanding to the beginners and developers who are willing to enhance their knowledge on the industry of SharePoint. 

Keep sharing the knowledge! :)