Friday, 27 November 2015

Create the BDC Service Application using the powershell for SharePoint 2013



Here a small script to provision the Business Data Connectivity Service Application-without ugly GUID in the database name.


  1. Add-PsSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
  2.  
  3. #Settings
  4. $ServiceName = "BDC Service"
  5. $ServiceProxyName = "BDC Proxy"
  6. $AppPoolAccount = "demo\spservices"
  7. $AppPoolName = "SharePoint Services App Pool"
  8. $DatabaseServer = "sp2013"
  9. $DatabaseName = "SP2013 BDC"
  10.  
  11. Write-Host -ForegroundColor Yellow "Checking if Application Pool Accounts exists"
  12. $AppPoolAccount = Get-SPManagedAccount -Identity $AppPoolAccount -EA 0
  13. if($AppPoolAccount -eq $null)
  14. {
  15. Write-Host "Please supply the password for the Service Account..."
  16. $AppPoolCred = Get-Credential $AppPoolAccount
  17. $AppPoolAccount = New-SPManagedAccount -Credential $AppPoolCred -EA 0
  18. }
  19.  
  20. Write-Host -ForegroundColor Yellow "Checking wether the Application Pool exists"
  21. $AppPool = Get-SPServiceApplicationPool -Identity $AppPoolName -ErrorAction SilentlyContinue
  22.  
  23. if (!$AppPool)
  24. {
  25. Write-Host -ForegroundColor Green "Creating Application Pool"
  26. $AppPool = New-SPServiceApplicationPool -Name $AppPoolName -Account $AppPoolAccount -Verbose
  27. }
  28.  
  29. Write-Host -ForegroundColor Yellow "Checking if BDC Service Application exists"
  30. $ServiceApplication = Get-SPServiceApplication -Name $ServiceName -ErrorAction SilentlyContinue
  31. if (!$ServiceApplication)
  32. {
  33. Write-Host -ForegroundColor Green "Creating BDC Service Application"
  34. $ServiceApplication = New-SPBusinessDataCatalogServiceApplication ApplicationPool $AppPool DatabaseName $DatabaseName DatabaseServer $DatabaseServer Name $ServiceName
  35. }
  36.  
  37. Write-Host -ForegroundColor Yellow "Starting the BDC Service"
  38. $ServiceInstance = Get-SPServiceInstance | Where-Object { $_.TypeName -like "*Business*" }
  39. Start-SPServiceInstance $ServiceInstance
  40.  
  41. Write-Host -ForegroundColor Green "Done - BDC Service is up and running."
Its basically an extended version of my Provision Search Service Application script, just a little cleaned-up. During the creation (some would say copy & paste) I wondered why the proxy is created automatically – at first I had two proxies.


No comments:

Post a Comment