CONFIGURING MULTITENANCY HOSTING IN SHAREPOINT 2010 AND SHAREPOINT 2013

If we consider a hosted environment like SharePoint Online it offers customers 2 mode of hosting
1. Standard: This is a shared infrastructure where multiple customers will be hosting their web applications/site collections (what we call as multi-tenant mode)
2. Dedicated: This is a separate infrastructure of the customer
Multitenancy is the ability to host unique deployments for multiple tenants on the same SharePoint server farm by isolating the data, operational services, and management of a tenant from other tenants using the same farm.
To achieve Multitenancy–based architectures requires a combination of
the following key capabilities:
➤ Site subscriptions
➤ Service application partitioning
➤ Tenant administration
➤ Feature packs

Create the Site subscriptions
• Create the Subscription Settings SA & Proxy
http://gallery.technet.microsoft.com/ScriptCenter/c6598b84-1a58-4d55-ab41-fe7608cb343c

Get-SPServiceInstance | where{$_.GetType().Name -eq "SPSubscriptionSettingsServiceInstance"} | Start-SPServiceInstance

$acc = Get-SPManagedAccount "sharepoint\spservices"
$appPool = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $acc

$app = New-SPSubscriptionSettingsServiceApplication –ApplicationPool $appPool –Name SettingsServiceApp –DatabaseName SettingsServiceDB
$proxy = New-SPSubscriptionSettingsServiceApplicationProxy –ServiceApplication $app

•Create new Site Subscription(s)
•Create Tenant Admin Site(s)
•Create Member Sites(s)
http://gallery.technet.microsoft.com/ScriptCenter/en-us/6b012e44-4262-4446-9112-a8b3133c4654
Get-SPServiceInstance | where{$_.GetType().Name -eq "SPSubscriptionSettingsServiceInstance"} | Start-SPServiceInstance
$acc = Get-SPManagedAccount "sharepoint\spservices"
$appPool = New-SPServiceApplicationPool -Name SettingsServiceAppPool -Account $acc
$app = New-SPSubscriptionSettingsServiceApplication –ApplicationPool $appPool –Name SettingsServiceApp –DatabaseName SettingsServiceDB
$proxy = New-SPSubscriptionSettingsServiceApplicationProxy –ServiceApplication $app

Service application partitioning


Get-SPServiceInstance | where{$_.GetType().Name -eq "MetadataWebServiceInstance"} | Start-SPServiceInstance

$pool = Get-SPServiceApplicationPool -Identity 'SharePoint Web Services Default'
$meta = New-SPMetadataServiceApplication -ApplicationPool $pool -Name 'Tenant Managed Metadata' -DatabaseName TenantMetadataDB -DatabaseServer sp2010 -PartitionMode

$proxy = New-SPMetadataServiceApplicationProxy -PartitionMode -ContentTypePushdownEnabled -DefaultKeywordTaxonomy -DefaultSiteCollectionTaxonomy -Name 'Tenant Managed Metadata Proxy' -DefaultProxyGroup -ServiceApplication $meta

Set-SPSiteSubscriptionMetadataConfig -identity $sub -serviceProxy $proxy -hubUri 'http://sp2010/mircosoft/mdhub'

Feature packs
http://gallery.technet.microsoft.com/ScriptCenter/d32274d0-e19c-4553-8556-3938671c95d9/

$sub = Get-SPSiteSubscription -identity GUID
$pack = New-SPSiteSubscriptionFeaturePack
$pack
Add-SPSiteSubscriptionFeaturePackMember -identity $pack -FeatureDefinition eaf6a128-0482-4f71-9a2f-b1c650680e77
$pack
$mgr = [Microsoft.SharePoint.SPSiteSubscriptionSettingsManager]::Local
$mgr.AssignFeaturePackToSiteSubscription($pack, $sub)

Advertisements

Powershell script for SharePoint 2010 & SharePoint 2007 Site Usage report

SharePoint 2010 & SharePoint 2007  – Powershell script for finding site Url, Title,user Count, Primary & Secondary Site collection admins, Usage, Hits, views, Created Date, last modifed date

[System.Reflection.Assembly]::Load(“Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”)
# get local farm
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local
# get web services from local farm
$websrvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]}
# format for .csv file output
$outputToCSV = @()
function CheckedOutItems()
{
    # get all web services available in the farm   
    foreach ($websrvc in $websrvcs) {
        # retrieve web applications
        foreach ($webApp in $websrvc.WebApplications) {
            # now get site collections from the web application
            foreach ($site in $webApp.Sites) {
                # process each web site
                Try {
                    foreach ($web in $site.AllWebs) {
                         $siteUrl = $web.Url
                         $siteName = $web.Title
                         $siteUserCnt = $web.AllUsers.Count
                         $PimarySiteAdmin = $site.Owner.Name
                         $SecondarySiteAdmin = $site.SecondaryContact.Name
                      $siteusage = $site.Usage.Storage/1MB
                         $Hits = $site.Usage.Hits                       
                         $Created = [datetime]$web.Created
                         $LastModified = $Web.LastItemModifiedDate
                         $SnapShot = (get-date)
                         $LastUpdate = ($SnapShot – [datetime]$LastModified)

                         $outputToCSV += New-Object PSObject -Property @{"Site Title" = $siteName; "Url" = $siteUrl; "Primary site collection admin"= $PimarySiteAdmin; 
                                                                        "Secondary site collection admin"=$SecondarySiteAdmin; "Total Users" =$siteUserCnt;"Size" = $siteusage; 
                                                                        "Date Last Modified" = $LastModified; "Days Last Update" = $LastUpdate; "Hits" =$Hits; "Date Created" =$Created
                                                                        }
                                        $file_date = get-date -format M-d-yyyy
                                        $file_name = "$env:USERPROFILE\Desktop\NoCheckedInVersion"+ $file_date + ".csv"
                                        $outputToCSV | ConvertTo-Csv -notype > $file_name

                } # end $site.AllWebs loop
            } # end Try statement 
            # General catch exceptions
            Catch {
                    "General Exceptions caught: " >> "$env:USERPROFILE\Desktop\errorlog.txt"
                    $_.Exception.Message >> "$env:USERPROFILE\Desktop\errorlog.txt"
            }# end general catch statement
            }
        }
    }
}
# Make a call to the function
CheckedOutItems

SharePoint 2010 – PowerGUI and the PowerGUI Extension for Visual Studio 2010

SharePoint 2010 – PowerGUI and the PowerGUI Extension for Visual Studio 2010

SharePoint 2010 – Powershell Script to Automatically deploy WSP packages

SharePoint 2010 –  Powershell Script to Automatically deploy WSP packages

packages = (dir *.wsp | Select-Object name)  
$currentDir = (Get-Location).Path  
Add-PSSnapin Microsoft.Sharepoint.PowerShell -ErrorAction "SilentlyContinue"
Start-SPAssignment -Global    # This cmdlet takes care of the disposable objects to prevent memory leak. 
Write-Host "Started package installation"
function WaitForJobToFinish ([string]$solutionName)    
{
     $JobName = "solution-deployment-$solutionName*"    
     $job = Get-SPTimerJob | ?{ $_.Name -like $JobName }    
 if ($job -eq $null)     
 {
         Write-Host "Timer job not found"
 }else
 {
  $JobFullName = $job.Name        
  Write-Host -NoNewLine "Waiting to finish job $JobFullName"            
  while ((Get-SPTimerJob $JobFullName) -ne $null)         
  {
   Write-Host -NoNewLine .
          Start-Sleep -Seconds 2        
  }
  Write-Host  "Finished waiting for job.."    
 }
foreach ($i in $packages)  
{  
    Write-Host -NoNewLine "Waiting for deployment jobs to finish..."            
    while ((Get-SPTimerJob  | ?{$_.Name -like "solution-deployment*"}) -ne $null)         
    {
     Write-Host -NoNewLine .
     Start-Sleep -Seconds 2        
    }
    Write-Host  "Finished waiting for job.."    
    Write-Host "Retracting: " + $i  
    $solution = (Get-SPSolution | where-object {$_.Name -eq $i.Name})  
    Write-Host $solution.Name  
    if ($solution -ne $null)  
    {  
      Write-Host "Solution Found..." 
     if ($solution.Deployed -eq $true)  
     {  
      Write-Host "Uninstalling..."
      try
      {
       Uninstall-SPSolution -Identity $i.Name -AllWebApplications -Confirm:$false
      }catch
      {
       Uninstall-SPSolution -Identity $i.Name -Confirm:$false  
      }
     }
     Write-Host "Retract Completed!" 
     Write-Host "Removing Solution..." 
     do{
  Write-Host -NoNewLine .
             Start-Sleep -Seconds 2
     }
     until ($solution.Deployed -eq $false)
     WaitForJobToFinish $i.Name
            Start-Sleep -Seconds 5
     Remove-SPSolution -Identity $i.Name -Force -Confirm:$false 
     Write-Host "Remove Completed!" 
    }  
    else 
    {  
     Write-Host "WSP Package was not previously installed, moving to next step" 
    }  
}  
foreach ($i in $packages) 
{  
    Write-Host "Deploying: " + $i  
    $solution = (Get-SPSolution | where-object {$_.Name -eq $i.Name})  
    if ($solution -eq $null)  
    {  
     Write-Host "Adding Solution..." 
     $solution = Add-SpSolution -LiteralPath ($currentDir + "\" + $i.Name)  
     WaitForJobToFinish $solution.Name
     Write-Host "Deployment Completed!" 
     Write-Host "Installing Solution..."
     try{
  Write-Host "Installing for web application(s)"
         Install-SPSolution -Identity $solution.Name -allwebapplications -GACDeployment -CASPolicies
      }
     catch 
     {
  Install-SPSolution -Identity $solution.Name -GACDeployment -CASPolicies
     }
    }  
}
}
Stop-SPAssignment -Global    # This cmdlet takes care of the disposable objects to prevent memory leak.
Remove-PsSnapin Microsoft.SharePoint.Powershell

Enabling Mime types using PowerShell Script

Enabling Mime types using PowerShell Script

[System.Reflection.Assembly]::Load("Microsoft.SharePoint, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c") | out-null  
$oContentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService;  
[Microsoft.SharePoint.Administration.SPWebApplicationCollection]$waColl = $oContentService.WebApplications;  
$waColl1 = $waColl | where-object {$_.IsAdministrationWebApplication -eq $FALSE}  
foreach ($wa in $waColl1)  
{  
                write-host "Web application " $wa.DisplayName
                $mimetype = "application/pdf"
                If ($wa.AllowedInlineDownloadedMimeTypes -notcontains $mimetype) 
                {
                                $wa.AllowedInlineDownloadedMimeTypes.Add($mimetype)
                                $wa.Update()
                                Write-Host -ForegroundColor Yellow "Added MIME type " $mimetype
                }
                Else
                {
                                Write-Host -ForegroundColor Green "MIME type " $mimetype " is already added."
                } 
                $mimetype = "application/vnd.ms-outlook"
                If ($wa.AllowedInlineDownloadedMimeTypes -notcontains $mimetype) 
                {
                                $wa.AllowedInlineDownloadedMimeTypes.Add($mimetype)
                                $wa.Update()
                                Write-Host -ForegroundColor Yellow "Added MIME type " $mimetype
                }
                Else
                {
                                Write-Host -ForegroundColor Green "MIME type " $mimetype " is already added."
                } 
}  
write-host "Finished."

Powershell script returns usernames and passwords of all SharePoint service

Powershell script returns usernames and passwords of all SharePoint service

# Bind to the local SharePoint farm
$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local

# Bind to the collection of all farm services
$spcredentials = $farm.Services | 
    # Sort farm services by type
    sort -Property TypeName | 
        # Only select those logical services that are backed up by a physical NT service,
        # excluding services not running under either a domain or LSA account `
        Where-Object {($_ -is [Microsoft.SharePoint.Administration.SPWindowsService]) `
            -and (($spi = $_.ProcessIdentity).Username -notlike "NT AUTHORITY\*")} | 
               # Store information about service account in a custom object through the Create-Object function
               # and store the object in the $spcredentials array
               ForEach-Object {Create-Object "Service" $_.TypeName $spi.Username $spi.Password}

# Bind to the collection of SPWebService instances in the farm and process them one by one
foreach ($ws in (New-Object -TypeName Microsoft.SharePoint.Administration.SPWebServiceCollection -ArgumentList $farm))
{
    # Bind to the collection of all IIS application pools associated with the current instance of SPWebService
    $spcredentials += $ws.ApplicationPools | 
        # Exclude pools not running under wither a domain or LSA account
        Where-Object {$_.Username -notlike "NT AUTHORITY\*"} | 
            # Store information about service account in a custom object through the Create-Object function
            # and store the object in the $spcredentials array 
            ForEach-Object {Create-Object "ApplicationPool" $_.Name $_.Username $_.Password}
}

# Return account information to the standard output
$spcredentials | Format-List