Thursday, 27 November 2014

File cannot be loaded because the execution of scripts is disabled on this system

There two to solve this error :

  • Set policy
  • By pass the policy
  1. Set policy
Set-ExecutionPolicy Unrestricted
or
Set-ExecutionPolicy RemoteSigned

     2. By pass the policy

powershell.exe -ExecutionPolicy ByPass -File script.ps1

Get Bulk Server IPS

  • List all server in sheet and save it by name "InputServerIPs.csv". And name column by name "ServerIPs".
example:
ServerIPs
server1
server2
.
.
.
server


  • Copy below code and paste in notepad and save by name GetServerIPs.ps1
  • Call the script according to environment. ex:
  • .\GetServerIPs.ps1 -env env1,
  • .\GetServerIPs.ps1 -env env2,
  • .\GetServerIPs.ps1 -env production
  • Get output in "OutputServerIPs.csv" in location where your "InputServerIPs.csv" is located.




param
(
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [System.String] $env
)
$data = Get-Content "C:\Users\sp_farm\InputServerIPs.csv"
$startDate =Get-Date
Write-host $startDate -ForegroundColor Red
$env1Domain = ".env1.net"
$env2Domain = ".env2.net"
$productionDomain = ".production.net"
if($env -eq "env1")
{
foreach($item in $data)
{
if($item -ne "ServerIPs")
{
try
{
$item
$server = $item + $env1Domain
$serverIP = ping $server
$getServerIP =$serverIP.GetValue(2)
$SpiltbyColon =$getServerIP.Split(":")
$splitbyfrom = $SpiltbyColon[0].Split("m")
$result = $item + ":" + $splitbyfrom[1]
}
catch
{
 $result = $item + ":" + "Not Found"
}
Write-Host $result -ForegroundColor Blue
write-output $result >> "C:\Users\sp_farm\OutputServerIPs.csv"
}
}
}
elseif($env -eq "env2")
{
foreach($item in $data)
{
if($item -ne "ServerIPs")
{
try
{
$item
$server = $item + $env2Domain
$serverIP = ping $server
$getServerIP =$serverIP.GetValue(2)
$SpiltbyColon =$getServerIP.Split(":")
$splitbyfrom = $SpiltbyColon[0].Split("m")
$result = $item + ":" + $splitbyfrom[1]
}
catch
{
 $result = $item + ":" + "Not Found"
}
Write-Host $result -ForegroundColor Blue
write-output $result >> "C:\Users\sp_farm\OutputServerIPs.csv"
}
}
}
else
{
foreach($item in $data)
{
if($item -ne "ServerIPs")
{
try
{
$item
$server = $item + $productionDomain
$serverIP = ping $server
$getServerIP =$serverIP.GetValue(2)
$SpiltbyColon =$getServerIP.Split(":")
$splitbyfrom = $SpiltbyColon[0].Split("m")
$result = $item + ":" + $splitbyfrom[1]
}
catch
{
 $result = $item + ":" + "Not Found"
}
Write-Host $result -ForegroundColor Blue
write-output $result >> "C:\Users\sp_farm\OutputServerIPs.csv"
}
}
}
$endDate = Get-Date
Write-host $endDate -ForegroundColor Green

Wednesday, 26 November 2014

Get time zone + window application

Create two label in form by name ISTTime and CSTTime which show time in IST and CST


{
TimeZone zone = TimeZone.CurrentTimeZone;


 DateTime local = zone.TolocalTime(DateTime.Now);


#get time zone information

TimeZoneInfo tzi = TimeZoneInfo.FindSystemTimeZoneById("Central Standard Time");


#get offset of the zone information


TimeSpan offset = tzi.GetUtcOffset(DateTime.UtcNow);


#Add offset to universal time
DateTime testDateTime = DateTime.UtcNow.Add(offset);


#display local and universal time in label
ISTTime.Text =local.ToString();


CSTTime.Text=testDateTime.ToString();
}

Tuesday, 25 November 2014

GetFileName + powershell

#get filename in $data variable
$data = get-content "directory:\Filepath\Filename"


#iterate the collection one by one and assign item variable
foreach($item in $data)
{
#get filename in filename variable
   $Filename = [System.IO.Path]::GetFileName($item)


#write output in output file
  write-output >> directory:\Filepath\output.csv
}

Thursday, 20 November 2014

Trust SSL + ServicePointManager.ServerCertificateValidationCallback Property

Trust SSL + ServicePointManager.ServerCertificateValidationCallback Property


Gets or sets the callback to validate a server certificate


An application can set the ServerCertificateValidationCallback property to a method to use for custom validation by the client of the server certificate. When doing custom validation, the sender parameter passed to the RemoteCertificateValidationCallback can be a host string name or an object derived from WebRequest (HttpWebRequest, for example) depending on the CertificatePolicy property.
When custom validation is not used, the certificate name is compared with host name used to create the request. For example, if Create(String) was passed a parameter of "https://www.contoso.com/default.hmtl", the default behavior is for the client to check the certificate against www.contoso.com.




Powershell Script:




$data = get-content InputLogs.csv
foreach($item in $data)
{
try
{
$Filename = [System.IO.Path]::GetFileName($item)


$tofile   = "D:\DownloadFiles\" + $Filename


$webclient = New-Object System.Net.WebClient

[Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}


$webclient.UseDefaultCredentials = $true


$webclient.DownloadFile($item, $tofile)
}
catch
{
write-output "$item" >> LogsExceptionCSV.csv

Write-Host Exception at $item and File not found
}
}


reference blogs:
https://social.technet.microsoft.com/Forums/windowsserver/en-US/a260da46-b035-478c-9887-ba5a0a4777a0/powershell-10-trust-any-ssl-cert


http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.servercertificatevalidationcallback(v=vs.110).aspx

Tuesday, 18 November 2014

Datasheet view + multilune text box of type enhance rich text box + SharePoint

Data sheet view with multiline text box column of  type enhanced do not allow you to edit item in datasheet view.


In standard view you are able edit item.


Multiline text box are of three types in SharePoint
  1. Plain
  2. Rich
  3. Enhanced


If you selected multiline text box of first two type then you are able to edit the item in datasheet view.
But if you are going with 3 option ENHANCED then it wont allow you to edit item in datasheet view.


Enhanced multiline text box is read only in Datasheet view.


Its an limitation with SharePoint Out of box features.

Monday, 17 November 2014

BCS SHAREPOINT 2013


                                                              BCS SHAREPOINT 2013

We’re often asked about what SharePoint’s Business Connectivity Service (BCS) in SharePoint 2010 and 2013  can be used for and how difficult it is to set up. While the short answer is pretty simple – BCS enables you to connect to ‘other’ data sources outside of SharePoint and literally treat them as a SharePoint List. For those that worked with the “Business Data Catalog” (BDC) in SharePoint 2007, be aware that BCS’s core is the BDC but with a significant change – instead of a one-way ‘view’ that was available in 2007, 2010/2013 feature ‘operations’ that provide two way usage (read, write, update, delete, etc.).
On a whiteboard it can be pretty easy to explain how to use it but it can be confusing since it requires setup in SQL Server, Central Administration and SharePoint Designer. For more advanced operations it can also include Visual Studio. That’s a lot of moving parts for some folks.
Since we provide a number of customized training programs, during the course of this we’ve created a simple step by step tutorial that has helped many of our clients and students get up to speed quickly. Not overly complex, the tutorial covers creating an external data source, creating an external content type and generating the list to use in a SharePoint site. To keep it simple, no coding of any kind is required.
In addition to the tutorial, we’ve also provided fixes for some of the most common issues and a list of some very useful links to dig into BCS further.

Services that allows integration of data which live outside the SharePoint in to the SharePoint and office products.
Data can be easily update and viewed on the remote systems and data can be easily integrated with authoritative sources.
Centralized infrastructure for managing connections to external sources.
Common interface for accessing data through out SharePoint.
Indexing data in eternal systems for searching on through SharePoint.
 



Here the steps for creating it: Data Source is SQL SERVER
Create a table/view from which you want to fetch data:

  • I created two table Customer and CustomerAddress above that I created view by name CustomerDetails.
  •  Create new External content types in SharePoint Designer
    • Name the external content type
      • Choose external systems
        • Add connection
          •  Select data source type
            • As you added the source with its name then all its objects get exposed to it.
            • As I added BCS Database to it then all object of BSC Database gets exposed to it.
              • Select the object on which CURD operation have to apply.
              • I choose Customer Details  
              • Map the identifie
              • Finish & save. Now External List is ready to use in SharePoint 2010/2013
              • Open CA
              • Open Business Data Connectivity Service
              • Here you get External list (new)
              • Set Object permission for it and then it will to perform CRUD operations. 
              • Create Eterna l List
              • Add the External Content Type and name it.
              • Open the list and get result which is similar to Database results.


 


 

NOTE:Please follow link for detailed information of BCS
Click Here ==>> Step by Step configuration of BCS in SharePoint 
https://code.msdn.microsoft.com/BCS-SHAREPOINT-20102013-63918778
Step by Step configuration of BCS Services in SharePoint 2010/2013
 Using BCS you can perform forward and backward data manipulation. But by using BDC you can perform only forward data manipulations.

Connectors Types:

SQL SERVER

WCF

.NET Managed Code

Custom

Wednesday, 12 November 2014

How to enable Developer Dashboard in SharePoint

#add snnapin if not


if((Get-PSSnapin Microsoft.SharePoint.Powershell) -eq $null)
{
    Add-Pssnapin Microsoft.SharePoint.Powershell
}


#enable developer dashboard SpDeveloperDashboardLevel = On


$services = [Microsoft.SharePoint.Administration.Spwebservice]::ContentService
$addsettings = $services.DeveloperDashboardSetting
$addsettings.DisplayLevel = [Microsoft.SharePoint.Administration.SpDeveloperDashboardLevel]::On
$addsettings.Update()

Monday, 10 November 2014

Number of item in List in SharePoint Site throughout web application

Introduction

Number of item in SharePoint list through out web application

Building the Sample

Script need to run where SharePoint Server is installed
Description
Get Spwepapplication =>spsite =>spweb =>webs
Then get all list in webs and get the count of item in lsit
$listitem = $List.Item.Count
 Please find below code for finding list item in all list in Web Application


#parameter declaration
param
(
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [System.String] $WebAppUrl,
[Parameter(Mandatory=$true,ValueFromPipelineByPropertyName=$true)] [System.String] $OutputFilePath
)
#check and add snappin
$snapin = Get-PSSnapin | Where-Object {
$_.Name -eq "Microsoft.SharePoint.Powershell"
}
if($snapin -eq $null){
Write-Host "Loading SharePoint Powershell Snnapin......."
Add-PSSnapin "Microsoft.SharePoint.Powershell"
}
#Creating table according to column values required
$startTime = Get-Date
Write-Host Script Starting time at $startTime -ForegroundColor Red
$table = New-Object system.Data.DataTable "Orphan Objects"
$WebTitle = New-Object system.Data.DataColumn WebTitle,([string])
$WebUrl = New-Object system.Data.DataColumn WebUrl,([string])
$ListTitle = New-Object system.Data.DataColumn ListTitle, ([String])
$ListUrl = New-Object system.Data.DataColumn ListUrl, ([String])
$ListItemCount = New-Object system.Data.DataColumn ListItemCount, ([String])
$table.columns.add($WebTitle)
$table.columns.add($WebUrl)
$table.columns.add($ListTitle)
$table.columns.add($ListUrl)
$table.columns.add($ListItemCount)
#iterating webapplication => spsite=> spweb=>web =>List
$allWebs = Get-SPWebApplication $WebAppUrl | Get-SPSite -Limit All | Get-SPWeb -Limit All
Foreach($webs in $allWebs)
{
foreach($List in  $webs.Lists)
{
$ListItemCount = $List.Items.Count
if($ListItemCount -gt 5000)
{
#write result to command prompt
 Write-Host List named $List.Title  has $ListItemCount records at $webs.Title -ForegroundColor Green
#write result to table
 $row = $table.NewRow()
           $row.WebTitle = $webs.Title
     $row.WebUrl = $webs.Url
     $row.ListTitle = $List.Title
     $row.ListUrl = $List.RootFolder.Url
     $row.ListItemCount = $ListItemCount
        $table.Rows.Add($row)
           $table.AcceptChanges()
}
}
}
$endTime = Get-Date
Write-Host Script Ending time at $endTime -ForegroundColor Red
#exporting data table to file
$table | Select-Object WebTitle, WebUrl, ListTitle, ListUrl, ListItemCount | Export-Csv $OutputFilePath -NoTypeInformation

Friday, 7 November 2014

Link of site or list appears but not working in SharePoint?

Some times when you try you click on link of lists or sites in (quick launch or view all site content)and its not working. Even though you have permission to see those list and sites. Its happens when sync between content database and SharePoint frontend gets broken.


Reason:


When error occurs during creating/Deleting sites/lists then SharePoint declare those sites as orphan sites\Lists.


When you look at lists/sites it appears in view all site content but when click on it. It will throw error.




Resolution:


Go to site content and structures


http://siteurl/_layouts/sitemager.aspx


then choose the sites/list that you wish delete and click on delete.

Thursday, 6 November 2014

Web Application Migration SP 2010 to SP 2013


How to migrate web application from SharePoint2010 to SharePoint2013?
Here the steps for doing the migration:

1.    Open Central  Administration of sp2010.Then go to Application Management:






















2.    Under Application management, Go to view all site collection

3.    Select the web application which you want to migrate.





After selecting the web application, copied its database name











4.    Open sql server management studio
5.    Take a back of the database before doing back up make the database read only.
6.    Right click on the database and go to properties.

    Now take backup of the database.
7.    Now your back up file is ready so you have copied down this file to destination server.
Which is SharePoint 2013 server.
8.    Now restore that back up file of the sp2010 database in Sp2013 server.
9.    Open Sql Server Management studio




10.    When you added the backup file here, please verify the backup media. If everything seems fine then take restore of it.


11.    Restore has been done. Files get added here.
12.    Next step is to mount this database to some web application of SharePoint 2013
13.    I choose create a new web application and mount db to it. But you can also choose existing web application.
14.    Open CA of SharePoint 2013. Under that click on Application management.

15.    Click on Manage Web Application

16.    Click on New on the ribbon




17.    Enter the web application name accordingly. No need to do any thing else. Just click on oK.




18.    Web application has been created in SP 2013
19.    Now we have to take offline the database which is in connected with this web application of SP2013. And then mount our SP2010 db to it.

20.    Go to application management => Click on Manage Content database.

21.    Choose the web application on which you want to mount sp2010 database.

22.    After the set the database status to offline and remove the content database.

23.    After remove content database then the web application is not associated to any web application.
24.    Now we have to mount database to web application by STSADM.EXE command.
STSADM.EXE –O  ADDCONTENTDB  -URL http://sitename –databasename wss_content_----------------
25.    After mounting, Please check the content database.

26.    If you mounted correctly then move forward and start web application.
27.    Initially you will get look and feel of sp 2010. Then click on Start now to get SP 2013 look and feel.





28.    This sp 2013 look and feel.

29.    You will get the whole content of SP2010 but you can not get custom branding of SP2010.
30.    For that customization is required at SP 2013.

Wednesday, 5 November 2014

RSS FEED

Introduction

RSS FEED

Really simple syndicate technology which is widely used for transmitting information across internet and intranet.
Sites offer rss feed which you can subscribe and gets information from source site.
You can also subscribe rss feed for sharepoint list/libraries.

Building the Sample

Needs to RSS feed setting is enable at web application level

  • Go to CA
  • Go to Application Management
  • Go to Manage Application and choose web application
  • Under ribbon , click on General settings
  • Check RSS field is checked or not. If not please checked it and saved.

Need to check rss feed is enable at site collection level.

  • Open site collection
  • Go to site Actions
  • Go to Site settings
  • Under Site collection administration => RSS
  • Click RSS
  • Check "allow rss at site collection" is checked or not. If not please enable it by checking.
  • Check "allow rss at site"

Now we are ready for implementing rss feed on the site.





Description
For implementing rss feed on the site we have to do two things:

  • First we need obtain source site rss feed url
  • Then we need add that url to some web part (rss viewer) or page

How to obtain rss feed url of some site.

Note : you will get rss feed url of only those site which were providing rss feed for their site.

Open the source site and then click on the rss feed sign which is on favorites bar.As you click on this sign source site is gets redirect to its rss site.




For example : I hit http://timesofindia.indiatimes.com/ then i click on rss feed sign in avorite bar , it redirect to its rss feed site url: http://timesofindia.indiatimes.com/rssfeeddefault.cms .

Please copied the rss feed url of the source site.

Open the page where you want to see rss feed result. RSS feed can be added to rss viewer webpart and page too.

Add rss viewer webpart to the page. Edit web part and add the "source rss feed url here". Click on save.

Now rss viewer will show the rss feed results.
 



More Information

How to set time interval for rss feed ?





  • Go to Site Action
  • Go to Site Settings
  • Click on RSS
  • Under Advance Setings , set Time to live = ?(minutes)
 
How to set item limit?
  • Open list/ library settings
  • under communication click on rss settings
  • Item Limit set here
  • Aslo set upto how manys days these data would be visibe in rss feed

Tuesday, 4 November 2014

List view threshold

List view threshold is termed as LVT.




SharePoint developer introduced this settings at web application level. In order to avoid the server performance issue. It really matters for server performance if you are about to view 1000 of records on the list. Because all the data is available at content database and view you open the list it fetch the records from the database and display on the list.


If you set 6000 LVT on the web application level then your list will allow to view only 6000 item on the list. On the backend what it does it fetches the 6000 records from the db and display these 6000 records accordingly on the view by setting number of item view on a page.


Its not advisable to increase the LVT by 5000.


How to set LVT:


  • Go to central administration
  • Go to Application Management
  • Manage Web Application
  • Choose web application
  • Under ribbon General Settings => drop down "Resource throttling"
  • List view threshold = set limit here(try to keep it less than 5000 if the environment is production else you can keep more).





Sunday, 9 March 2014

Native SQL install Bootstrapper has not working?

cause: A setup file if your SQL SERVER gets corrupted.

Symptoms : on click on setup file , giving error "Native SQL install Bootstrapper has not working"

Resolution :
1) Dump previous installations file.
    Go to task manger, then disable all services except Microsoft services.
    Select Load Start up option
   OR

2) Then, goto control panel, goto program. then click on turn on/off windows features.
     Select all .net framework 3.5.1 options.
     click ok.

Give restart to to machine.