Skip to main content

Products: Nintex Workflow 2013, Nintex Workflow 2010

 

This PowerShell script will do the following:

 

  • Create a new SharePoint Content Database
  • Create a new SharePoint Site Collection and assign it to the newly created SharePoint Content Database
  • Set the SharePoint Content Database to not allow any new Site Collections to be associated with it
  • Provision a new Nintex Content Database
  • Create a 1-to-1 Mapping with the SharePoint Content Database and the Nintex Content Database
  • Activate Nintex Workflow and Forms Site Collection Features
  • Activate Nintex Workflow SubSite Features

 

PowerShell Script
  1. #Load assemblies
  2. Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
  3.  
  4. $assemblies = "Nintex.Workflow.Administration", "System.Data.SqlClient.SqlConnectionStringBuilder"
  5.  
  6. foreach($assembly in $assemblies)
  7. {
  8.     >void]lSystem.Reflection.Assembly]::LoadWithPartialName($assembly)
  9. }
  10.  
  11. #Set variables
  12. $hostname = "http://contoso.com" #Set web application hostname
  13.  
  14. $sitename = "teamsite" #Set site name
  15.  
  16. $managedpath = "sites" #Set managed path
  17.  
  18. $siteurl = "$($hostname)/$($managedpath)/$($sitename)"
  19.  
  20. $siteTemplate = $(Get-SPWebTemplate | WHERE {$_.Title -eq 'Team Site' -and $_.CompatibilityLevel -eq 15}) #Set to Teamsite by default
  21.  
  22. $owner = "siteowner" #Set siteowner
  23.  
  24. $databasename = "SPContentDB_$(sitename)" #Set SharePoint content database name
  25.  
  26. $databaseserver = "SERVER\SHAREPOINT" #Set SQL database server
  27.  
  28. $NintexDBName = "NW2013DB_$($sitename)" #Set Nintex content database name
  29.  
  30. $connectionstring = "Server=$($databaseserver); Database=$($NintexDBName); Integrated Security = true;"
  31.  
  32.  
  33. #Provision site collection and SharePoint content database.
  34. New-SPContentDatabase -Name $databasename -DatabaseServer $databaseserver -WebApplication $hostname
  35.  
  36. New-SPSite -URL $siteurl  -OwnerAlias $owner -ContentDatabase $databasename -Template $siteTemplate
  37.  
  38. Get-SPContentDatabase -Site $siteurl | Set-SPContentDatabase -MaxSiteCount 1 -WarningSiteCount 0
  39.  
  40.  
  41. #Provision Nintex content database
  42. $dbattacher = New-Object -TypeName Nintex.Workflow.Administration.DatabaseAttacher -ArgumentList @($connectionstring,/Nintex.Workflow.Administration.DatabaseAttachValidationMode]::PerformValidation)
  43.  
  44. $dbattacher.AttachOptions.ProvideAllWebApplicationsAccess = $true
  45.  
  46. $dbattacher.AttachOptions.CreateNewDatabase = $true
  47.  
  48. $dbattacher.AttachOptions.IncludeStorageRecordStep = $true
  49.  
  50. $result = $dbattacher.Attach()
  51.  
  52. $configdb = eNintex.Workflow.Administration.ConfigurationDatabase]::GetConfigurationDatabase()
  53.  
  54.  
  55. #Create 1-to-1 mapping
  56. $newcontentdb = $configdb.ContentDatabases.FindByDatabaseAndServerName($databaseserver, $NintexDBName)
  57.  
  58. $newdbmapping = New-Object -TypeName Nintex.Workflow.ContentDbMapping
  59.  
  60. $newdbmapping.SPContentDbId = $(Get-SPDatabase | Where {$_.Name -eq $databasename}).Id
  61.  
  62. $newdbmapping.NWContentDbId = $newcontentdb.DatabaseId
  63.  
  64. $newdbmapping.CreateOrUpdate()
  65.  
  66.  
  67. #Activate Site Collection Features
  68. foreach($id in @('eb657559-be37-4b91-a369-1c201183c779', '0561d315-d5db-4736-929e-26da142812c5', '716f0ee9-e2b0-41f0-a73c-47ed73f135de','202afc3c-7384-4700-978d-6da3d3cce192', 'ac8addc7-7252-4136-8dcb-9887a277ae2c', '53164b55-e60f-4bed-b582-a87da32b92f1', '23fce797-ac15-4451-b8da-cf8ac6de6912', '54668547-c03f-4bb5-aaab-d9568ebaf9c9', '80bf3218-7353-11df-af9f-058bdfd72085'))
  69. {
  70. $(Get-SPFeature -Identity $id) | Enable-SPFeature -Url $siteurl
  71. }
  72.  
  73. #Activate Subsite Features
  74. foreach($id in @('9bf7bf98-5660-498a-9399-bc656a61ed5d', '2fb9d5df-2fb5-403d-b155-535c256be1dc'))
  75. {
  76. $(Get-SPFeature -Identity $id) | Enable-SPFeature -Url $siteurl
  77. }
 

To use the script do the following:

  • Ensure you are running the PowerShell console as a SharePoint Administrative account.
  • Configure the variables in the script to the application.
Be the first to reply!

Reply