Wednesday, July 25, 2018

Search Service configuration to Single server under (2 WFE+1 SQL+1Search)


Run the below commands to SP 2016 Search server


$App1 = "MCMYPSPA01"

$SearchAppPoolName = "SharePoint Search Application pool"
$SearchAppPoolAccountName = "apps\svc.srch"
$SearchServiceName = "SharePoint Search Service Application"
$SearchServiceProxyName = "SharePoint Search Proxy"
$DatabaseName = "SP_Prod_AppFarmA_Search_AdminDB"
 
#Create a Search Service Application Pool
$spAppPool = New-SPServiceApplicationPool -Name $SearchAppPoolName -Account $SearchAppPoolAccountName -Verbose

#Start Search Service Instance on all Application Servers
Start-SPEnterpriseSearchServiceInstance $App1 -ErrorAction SilentlyContinue
#Start-SPEnterpriseSearchServiceInstance $App2 -ErrorAction SilentlyContinue
Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $App1 -ErrorAction SilentlyContinue
#Start-SPEnterpriseSearchQueryAndSiteSettingsServiceInstance $App2 -ErrorAction SilentlyContinue

#Create Search Service Application
$ServiceApplication = New-SPEnterpriseSearchServiceApplication -Partitioned -Name $SearchServiceName -ApplicationPool $spAppPool.Name -DatabaseName $DatabaseName

#Create Search Service Proxy
New-SPEnterpriseSearchServiceApplicationProxy -Partitioned -Name $SearchServiceProxyName -SearchApplication $ServiceApplication

#----------------------------------------------------

$clone = $ServiceApplication.ActiveTopology.Clone()
$App1SSI = Get-SPEnterpriseSearchServiceInstance -Identity $App1

#We need only one admin component
New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $App1SSI

#We need content processing components
New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $App1SSI


#We need analytics processing components
New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $App1SSI


#We need crawl components
New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $App1SSI


#We need query processing components
New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $App1SSI


#---------------------------------------------------------

#Set the primary and replica index location; ensure these drives and folders exist on application servers
$PrimaryIndexLocation = "E:\SharePoint\index\Data"

#We need index partitions and replicas for each partition. Follow the sequence.
New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $App1SSI -RootDirectory $PrimaryIndexLocation -IndexPartition 0
$clone.Activate()



Monday, July 9, 2018

Enable Anonymous SharePoint 2013/ SharePoint 2016 site Access on mobile


Problem : After making the sharepoint site Anonymous,  I was still getting the authentication prompt in mobile.
Fix : 
Deactivate the site-collection feature (Unlimited-access user permission lockdown mode) 
SiteCollection Feature needs to be deactivate for Mobile .


Wednesday, July 12, 2017

Get the Lync Server Details for Migration


Run the below command on Lync FE server

1) Get-WmiObject -query 'select * from win32_product' | where {$_.name -like "*Lync Server*"} | ft Name, Version -AutoSize >c:\version.txt


Tuesday, October 11, 2016

Server information as a wall paper utility BGINFO




https://technet.microsoft.com/en-us/sysinternals/bginfo.aspx

 If you manage multiple computers you probably need BGInfo. It automatically displays relevant information about a Windows computer on the desktop's background, such as the computer name, IP address, service pack version, and more. You can edit any field as well as the font and background colors, and can place it in your startup folder so that it runs every boot, or even configure it to display as the background for the logon screen.

Tuesday, August 30, 2016

Rollback SharePoint WSP deployed as a Farm sollution

Download XML file used as a config file for this script.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
Param([Parameter(Mandatory=$True)]
       [string]$Environment
     )

$snapinName = "Microsoft.SharePoint.PowerShell"
if ((Get-PSSnapin | Where-Object {$_.Name -eq $snapinName }) -eq $NULL) {
  write-host "SharePoint SnapIn not loaded. Loading..."
  Add-PSSnapin $snapinName -ErrorAction SilentlyContinue
  }
#####################################################################

$Envpath=(Get-Location -PSProvider FileSystem).ProviderPath
write-host "Envpath" $Envpath
Write-Host 'Select Current Environment'
Write-Host 'DEV'
Write-Host 'INT'
Write-Host 'QA'
Write-Host 'STAGE'
Write-Host 'PROD'
$Env= $Environment

Write-Host  'Current environment selected' + $Env

if($Env -eq 'DEV')
{
$EnvName='Dev'
}
elseif($Env -eq 'INT')
{
$EnvName='DevInt'
}
elseif($Env -eq 'QA')
{
$EnvName='QA'
}
elseif($Env -eq 'STAGE')
{
$EnvName='Stage'
}
elseif($Env -eq 'PROD')
{
$EnvName='Prod'
}



$Envpath=(Get-Location -PSProvider FileSystem).ProviderPath
write-host "Envpath" $Envpath

#get the Config.xml file from te deployment package
$configpath = $Envpath + "\config.xml"
[xml] $configXml = Get-Content $configpath -ErrorAction SilentlyContinue

#####################################################################

#method to read cofig values from config.xml file -start

#####################################################################
function Get-ConfigValue
{
 Param(
  [string] $key
 )
 Process
 {
  $xpath = "Configuration/$EnvName/param[@key='" + $key + "']" + "/text()"
  $configXml.SelectSingleNode($xpath).Value
 }
}

$SiteCollectionURL=Get-ConfigValue "SiteCollectionUrl"
Write-Host "SiteCollection url:" $SiteCollectionURL

 
$solutionName = "Declaration_Email.wsp"
 
$solution = Get-SPSolution $solutionName
 
Write-Host -ForegroundColor Green "Removing $solutionName"
Write-Host ""
 
if( $solution.Deployed -eq $true) {
 
    if ( $solution.ContainsWebApplicationResource ) {
        Uninstall-SPSolution -Identity $solutionName -Confirm:$false -Webapplication  $SiteCollectionURL
    }
    else {
        Uninstall-SPSolution -Identity $solutionName -Confirm:$false
    }
    $counter = 1
    $maximum = 50
    $sleeptime = 2
    while( $solution.JobExists -and ( $counter -lt $maximum ) ) {
        Write-Host -ForegroundColor yellow "Retracting $solutionName. Please wait..."
        sleep $sleeptime
        $counter++
    }
}
 
Write-Host ""
Write-Host -ForegroundColor Green "$solutionName is retracted."
Write-Host ""
 
Remove-SPSolution -Identity $solutionName -Force -Confirm:$false
 
Write-Host -ForegroundColor Green "$solutionName removed."

Deploy Sharepoint WSP using powershell script using custom config file


Download   XML file (config file) used for this powershell script

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
Param([Parameter(Mandatory=$True)]
       [string]$Environment
     )
$snapinName = "Microsoft.SharePoint.PowerShell"
if ((Get-PSSnapin | Where-Object {$_.Name -eq $snapinName }) -eq $NULL) {
  write-host "SharePoint SnapIn not loaded. Loading..."
  Add-PSSnapin $snapinName -ErrorAction SilentlyContinue
  }
#####################################################################



$Envpath=(Get-Location -PSProvider FileSystem).ProviderPath
write-host "Envpath" $Envpath
#Select the Environment to setup and deploy GRR 
Write-Host 'Select Current Environment'
Write-Host 'DEV'
Write-Host 'INT'
Write-Host 'QA'
Write-Host 'STAGE'
Write-Host 'PROD'
$Env= $Environment

Write-Host  'Current environment selected' + $Env

if($Env -eq 'DEV')
{
$EnvName='Dev'
}
elseif($Env -eq 'INT')
{
$EnvName='DevInt'
}
elseif($Env -eq 'QA')
{
$EnvName='QA'
}
elseif($Env -eq 'STAGE')
{
$EnvName='Stage'
}
elseif($Env -eq 'PROD')
{
$EnvName='Prod'
}



$Envpath=(Get-Location -PSProvider FileSystem).ProviderPath
write-host "Envpath" $Envpath

#get the WSP file path
$solutionName = "Declaration_Email.wsp"
$WSPFilepath = $Envpath + "\Declaration_Email.wsp"

#get the Config.xml file from te deployment package
$configpath = $Envpath + "\config.xml"
[xml] $configXml = Get-Content $configpath -ErrorAction SilentlyContinue

#####################################################################

#method to read cofig values from config.xml file -start

#####################################################################
function Get-ConfigValue
{
 Param(
  [string] $key
 )
 Process
 {
  $xpath = "Configuration/$EnvName/param[@key='" + $key + "']" + "/text()"
  $configXml.SelectSingleNode($xpath).Value
 }
}


 Write-Host "Applying changes to DEV config file"
 $SiteCollectionURL=Get-ConfigValue "SiteCollectionUrl"
  Write-Host "SiteCollection url:" $SiteCollectionURL
  Write-Host "Adding solution.." -foregroundcolor Yellow
 # LogInfoMessage "Adding solution in Dev started" 
 
  Write-Host "Install solution.." -foregroundcolor Yellow
  
    $solution = Add-SPSolution $WSPFilepath
  
 #LogInfoMessage "Solution added" 
 
  Write-Host "Solution added.." -foregroundcolor Yellow
 
if ( $solution.ContainsWebApplicationResource ) {
    Write-Host -ForegroundColor Green "Deploying $solutionName to $url"
    Install-SPSolution -Identity $solutionName -Webapplication $SiteCollectionURL -FullTrustBinDeployment -GACDeployment -Force
 
}
else {
    Write-Host -ForegroundColor Green "Deploying $solutionName"
    Install-SPSolution -Identity $solutionName -GacDeployment -Force
}
 
$solution = Get-SPSolution $solutionName
 
if ($solution.Deployed -eq $false ) {
    $counter = 1
    $maximum = 50
    $sleeptime = 2
    while( ($solution.JobExists -eq $true ) -and ( $counter -lt $maximum  ) ) {
        write-host -ForegroundColor yellow "Please wait..."
        sleep $sleeptime
        $counter++
    }
}
 
Write-Host ""
Write-Host -ForegroundColor Green "$solutionName is deployed"

Tuesday, June 14, 2016

Get REST data from SharePoint List more than 50 items

   $.ajax({
                  type: 'GET',
                  url: url +"_api/web/lists/getbytitle('ReportingList')/Items?$skiptoken=Paged=TRUE&$top=1000&$select= CountryCodeInMap,CountryColourInMap",
                  headers: { "Accept": "application/json;odata=verbose" },
                  cache: false,
                  success: function (data) {
                      var colordata = '{';
                      for (i = 0; i < data.d.results.length; i++) {
                          if (data.d.results[i].CountryCodeInMap != null) {
                              colordata = colordata + '"' + data.d.results[i].CountryCodeInMap + '":' + '"' + data.d.results[i].CountryColourInMap + '"';
                              colordata = colordata + ",";
                          }
                      }
                      var data = colordata.substring(0, colordata.length - 1) + '}';
                      renderMap();
                      var jsondata = $.parseJSON(data);
                      jQuery('#vmap').vectorMap('set', 'colors', jsondata);
                  },
                  error: function (status) {
                      renderMap();
                      DisplayErrorMessage("Error loading world map.");
                  }
              });
          });

HTML

Script:

JS