Subscribe:

Labels

Thursday, September 27, 2018

Update BDC service Throttling size


Add-PSSnapin "Microsoft.SharePoint.PowerShell"
 $bdcAppProxy = Get-SPServiceApplicationProxy | where {$_ -match "BDC Service"}
 Get-SPBusinessDataCatalogThrottleConfig -Scope Database -ThrottleType Items -ServiceApplicationProxy $bdcAppProxy
 $throttleDb = Get-SPBusinessDataCatalogThrottleConfig -Scope Database -ThrottleType Items -ServiceApplicationProxy $bdcAppProxy

Set-SPBusinessDataCatalogThrottleConfig -Identity $throttleDb -maximum 8000000 -default 4000000

Get all site collections Used space and hits


function GetAllWebApplications()
{

 write-host "Sitecollection List Extraction started...." -foregroundcolor yellow
 $webApps = Get-SPWebApplication

 foreach($webApp in $webApps)
 {
 Write-Host "Web Application : " $webApp.name "web URl :" $webApp.Url


 #Fetch the site collections from the web application.
 GenerateAllSitecollectionsInWebapplication $webApp.Url $webApp.ContentDatabases.Name
 }
}


function GenerateAllSitecollectionsInWebapplication ($url , $webAppCntDB)
{

 try
 {

 $rootSite = New-Object Microsoft.SharePoint.SPSite($url)

 $spWebApp = $rootSite.WebApplication

  
 foreach($spSite in $spWebApp.Sites)
 {

 try{

  $list = $spSite.url
 write-host $list -foregroundcolor green
 
 #Code to get the storage used in MB's
 [int]$usage = $spSite.usage.storage/1MB

 #Code to get the quota template name
 $contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
 $quotaTemplate = $contentService.QuotaTemplates | where {$_.QuotaID -match $spSite.Quota.QuotaID}

 write-host  $outputString -ForegroundColor Green | Format-Table –AutoSize

$WebApp = $url
$siteCollurl = $spSite.Url
$contDB = $spSite.ContentDatabase.Name
$siteCollSize = $usage.ToString() + " MB"
$prowner=""
if(![string]::IsNullOrEmpty($spSite.Owner))
{
$prowner = $spSite.Owner.ToString().split('|')[1]
}
$sconwer=""
if(![string]::IsNullOrEmpty($spSite.SecondaryContact))
{
$sconwer = $spSite.SecondaryContact.ToString().split('|')[1]
}
[int]$hits = $spSite.Usage.Hits
[int]$visits = $spSite.Usage.Visits

$lastModifiedDate = ""
if(![string]::IsNullOrEmpty($spSite.LastContentModifiedDate))
{
$lastModifiedDate = $spSite.LastContentModifiedDate.ToString().split(' ')[0].ToString()
}

 $strFileName = "c:\inside-new.xlsx"
$strProvider = "Provider=Microsoft.ACE.OLEDB.12.0"
$strDataSource = "Data Source ="+$strfilename
$strExtend = "Extended Properties=Excel 8.0"

$objConn = new-object System.Data.OleDb.OleDbConnection( ` "$strProvider;$strDataSource;$strExtend")
$sqlCommand = new-object System.Data.OleDb.OleDbCommand($strQuery)

$objConn.open()
$sqlCommand.Connection = $objConn

$strQuery = "Insert into [Sheet1$] (WebApplication,URL,ContentDatabase,SiteCollectionSize,PrimaryOwner,SecondaryOwner,NoOfHits,NoOfVisits,LastModifiedDate) values('$WebApp','$siteCollurl','$contDB','$siteCollSize','$prowner','$sconwer',$hits,$visits,'$lastModifiedDate')"
$sqlCommand.CommandText = $strQuery
$sqlCommand.ExecuteNonQuery()

$objConn.Close()
}
catch
{

$WebApp = $url
$siteCollurl = $spSite.Url
$contDB = $spSite.ContentDatabase.Name
$siteCollSize = $usage.ToString() + " MB"
$prowner=""
if(![string]::IsNullOrEmpty($spSite.Owner))
{
$prowner = $spSite.Owner.ToString().split('|')[1]
}
$sconwer=""
if(![string]::IsNullOrEmpty($spSite.SecondaryContact))
{
$sconwer = $spSite.SecondaryContact.ToString().split('|')[1]
}
[int]$hits = $spSite.Usage.Hits
[int]$visits = $spSite.Usage.Visits

$lastModifiedDate = ""
if(![string]::IsNullOrEmpty($spSite.LastContentModifiedDate))
{
$lastModifiedDate = $spSite.LastContentModifiedDate.ToString().split(' ')[0].ToString()
}

 $strFileName = "c:\inside-new.xlsx"
$strProvider = "Provider=Microsoft.ACE.OLEDB.12.0"
$strDataSource = "Data Source ="+$strfilename
$strExtend = "Extended Properties=Excel 8.0"

$objConn = new-object System.Data.OleDb.OleDbConnection( ` "$strProvider;$strDataSource;$strExtend")
$sqlCommand = new-object System.Data.OleDb.OleDbCommand($strQuery)

$objConn.open()
$sqlCommand.Connection = $objConn

$strQuery = "Insert into [Sheet1$] (WebApplication,URL,ContentDatabase,SiteCollectionSize,PrimaryOwner,SecondaryOwner,NoOfHits,NoOfVisits,LastModifiedDate) values('$WebApp','$siteCollurl','$contDB','$siteCollSize','$prowner','$sconwer',$hits,$visits,'$lastModifiedDate')"
$sqlCommand.CommandText = $strQuery
$sqlCommand.ExecuteNonQuery()

$objConn.Close()

}

 }



 }
 catch
 {

 $WebApp = $url
$siteCollurl = ""
$contDB = $webAppCntDB
$siteCollSize = ""
$prowner=""

$sconwer=""

[int]$hits = 0;
[int]$visits = 0;

$lastModifiedDate = ""


 $strFileName = "c:\inside-new.xlsx"
$strProvider = "Provider=Microsoft.ACE.OLEDB.12.0"
$strDataSource = "Data Source ="+$strfilename
$strExtend = "Extended Properties=Excel 8.0"

$objConn = new-object System.Data.OleDb.OleDbConnection( ` "$strProvider;$strDataSource;$strExtend")
$sqlCommand = new-object System.Data.OleDb.OleDbCommand($strQuery)

$objConn.open()
$sqlCommand.Connection = $objConn

$strQuery = "Insert into [Sheet1$] (WebApplication,URL,ContentDatabase,SiteCollectionSize,PrimaryOwner,SecondaryOwner,NoOfHits,NoOfVisits,LastModifiedDate) values('$WebApp','$siteCollurl','$contDB','$siteCollSize','$prowner','$sconwer',$hits,$visits,'$lastModifiedDate')"
$sqlCommand.CommandText = $strQuery
$sqlCommand.ExecuteNonQuery()

$objConn.Close()


 write-host "Unable to Extract Site Collections , May be Sitecollections does not Exist..." -foregroundcolor red
 continue
 }


}


cls

Add-PSSnapin "Microsoft.Sharepoint.Powershell"

 GetAllWebApplications


 write-host "Completed Extracting all the Site collections" -ForegroundColor Yellow

Creating Subsite in Top level site collection.


#Creating Sub Sites in top site collection.
 Write-Output " "
 Write-Output "Creating Sub Sites"

$SiteCollectionURL = "http://abc.com"

#$SiteCollectionTemplate = "STS#0"

$SiteCollectionLanguage = 1033

$SubSites = @("ISubSite1")

 for($i=0 ; $i -lt $SubSites.count ; $i++)
 {
 $SiteUrl = ""
 $SiteUrl = $SiteCollectionURL + "/"
 $SiteUrl = $SiteUrl += $SubSites[$i]
 Write-Output " "
 #Write-Output "Creating Site for " += $SubSites[$i]
 Write-Output " "
 #"created url - "+$SiteUrl
 New-SPWeb $SiteUrl -Name $SubSites[$i]  -UseParentTopNav -Language $SiteCollectionLanguage
 Write-Output "Created the site"+$SiteUrl
 Write-Output "Importing the site"+$SiteUrl
 Import-SPWeb -Identity $SiteUrl -Path "C:\TEMP\bkinsiderep.cmp" -IncludeUserSecurity -Force
 #Write-Output "Site Created for " += $SubSites[$i]
 Write-Output " "
 }

# Remove-PsSnapin Microsoft.SharePoint.PowerShell