WorkFlow Install Scripts

Sep 25, 2013 at 11:13 PM
Howdy, I was wondering if you might be interested in scripts that install and config workflow to add to your package.
Sep 26, 2013 at 3:54 PM
I would be interested in seeing how you have it script. I have created many custom function to do additional things.
Sep 26, 2013 at 4:34 PM
TanKCR,

Why not post them here or better yet, submit a change set.
Sep 27, 2013 at 3:14 PM
As soon as I have a few moments I will do just that, though I am currently in the middle of a ShP 2013 deployment so it may be a few days.
Jan 6 at 5:58 PM
TanKCR,
Any word on your workflow script?
Jan 6 at 7:10 PM
Hey yea, haven't had a ton of time, I made it mostly generic and can post it for you. Couple of things, I never got around to checking and installing pre0reqs with the script, and it also uses a couple of ENV value's that we set, but those should be too hard to get rid of and integrate. I will add a seperate reply with just the code.
Jan 6 at 7:13 PM
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction "SilentlyContinue"
CD "C:\Program Files\Workflow Manager\1.0\Scripts"
./ImportWorkflowModule.ps1

$SBKey = 'SBKeyyouwant'
$WFMKey = 'WFKeyyouwant'
$CURENV = (Get-ChildItem env:HOME_CURENV).value
$domain = (Get-ChildItem env:domain).value
$app = $domain +'\serviceaccount'
$sbcatalog = ('SB_'+$CURENV+'_Management')
$GatewayDB = ('SB_'+$CURENV+'_GatewayDatabase')
$MSGCont = ('SB_'+$CURENV+'_MessageContainer')
$WFCat = ('WF_'+$CURENV+'_Management')
$WFInst = ('WF_'+$CURENV+'_InstanceManagement')
$WFResource = ('WF_'+$CURENV+'_ResourceManagement')

# To be run in Workflow Manager PowerShell console that has both Workflow Manager and Service Bus installed.
# Create new SB Farm
$SBCertificateAutoGenerationKey = ConvertTo-SecureString -AsPlainText  -Force  -String $SBKey -Verbose;
New-SBFarm -SBFarmDBConnectionString "Data Source=SQLALIAS;Initial Catalog=$sbcatalog;Integrated Security=True;Encrypt=False" -InternalPortRangeStart 9000 -TcpPort 9354 -HttpsPort 9355 -MessageBrokerPort 9356 -RunAsAccount ($domain + '\serviceaccount') -AdminGroup ($domain + '\youradmingroup') -GatewayDBConnectionString "Data Source=SQLALIAS;Initial Catalog=$GatewayDB;Integrated Security=True;Encrypt=False" -CertificateAutoGenerationKey $SBCertificateAutoGenerationKey -MessageContainerDBConnectionString "Data Source=SQLALIAS;Initial Catalog=$MSGCont;Integrated Security=True;Encrypt=False" -Verbose;

# Create new WF Farm
$WFCertAutoGenerationKey = ConvertTo-SecureString -AsPlainText  -Force  -String $WFMKey -Verbose;
New-WFFarm -WFFarmDBConnectionString "Data Source=SQLALIAS;Initial Catalog=$WFCat;Integrated Security=True;Encrypt=False" -RunAsAccount ($domain + '\serviceaccount') -AdminGroup ($domain + '\admingroup') -HttpsPort 12290 -HttpPort 12291 -InstanceDBConnectionString "Data Source=SQLALIAS;Initial Catalog=$WFInst;Integrated Security=True;Encrypt=False" -ResourceDBConnectionString "Data Source=SQLALIAS;Initial Catalog=$WFResource;Integrated Security=True;Encrypt=False" -CertificateAutoGenerationKey $WFCertAutoGenerationKey -Verbose;

# Add SB Host
$SBRunAsPassword = ConvertTo-SecureString -AsPlainText  -Force  -String $SBKey -Verbose;


Add-SBHost -SBFarmDBConnectionString "Data Source=SQLALIAS;Initial Catalog=$sbcatalog;Integrated Security=True;Encrypt=False" -RunAsPassword $SBRunAsPassword -EnableFirewallRules $true -CertificateAutoGenerationKey $SBCertificateAutoGenerationKey -Verbose;

Try
{
    # Create new SB Namespace
    New-SBNamespace -Name 'WorkflowDefaultNamespace' -AddressingScheme 'Path' -ManageUsers ($domain + '\serviceaccount'),'YourAccount@YourDomain' -Verbose;

    Start-Sleep -s 90
}
Catch [system.InvalidOperationException]
{
}

# Get SB Client Configuration
$SBClientConfiguration = Get-SBClientConfiguration -Namespaces 'WorkflowDefaultNamespace' -Verbose;

# Add WF Host
$WFRunAsPassword = ConvertTo-SecureString -AsPlainText  -Force  -String $WFMKey -Verbose;


Add-WFHost -WFFarmDBConnectionString "Data Source=SQLALIAS;Initial Catalog=$WFCat;Integrated Security=True;Encrypt=False" -RunAsPassword $WFRunAsPassword -EnableFirewallRules $true -SBClientConfiguration $SBClientConfiguration -EnableHttpPort  -CertificateAutoGenerationKey $WFCertAutoGenerationKey -Verbose;

# Register Workflows to all site collections

[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.SharePoint") > $null 

$farm = [Microsoft.SharePoint.Administration.SPFarm]::Local 
$CURENWEB = (Get-ChildItem env:HOME_HOST_HEADER).value
$MYSITEWEB = "http://" + (Get-ChildItem env:MYSITE_URL).value
$URL = "http://" + $CURENWEB
$websvcs = $farm.Services | where -FilterScript {$_.GetType() -eq [Microsoft.SharePoint.Administration.SPWebService]} 
$CURENENV = (Get-ChildItem env:HOME_CURENV).value
$webapps = @()
$domain = (Get-ChildItem env:domain).value
$WFFARM = Get-WFFarm
if (($WFFARM.Hosts | Where-Object {$_.Name -ilike '*web*'}).Name -inotlike $NULL){
    $WFURL = ("http://"+($WFFARM.Hosts | Where-Object {$_.Name -ilike '*app*'}).Name+":"+$WFFARM.httpport)
 
    if ((Get-ChildItem env:HOME_CURENV).value -eq 'Production')
        {$AppsCENTERURL = ('http://Apps.'+$domain)
        $TITLE = 'Web'
        $SEARCHURL = ('http://Search.'+$domain)}
    if ((Get-ChildItem env:HOME_CURENV).value -eq 'Dev')
        {$AppsCENTERURL = ('http://Apps-Dev.'+$domain)
        $TITLE = 'Web-Dev'
        $SEARCHURL = ('http://Search-Dev.'+$domain)}
    if ((Get-ChildItem env:WEB_HOME_CURENV).value -eq 'QA')
        {$AppsCENTERURL = ('http://Apps-QA.'+$domain)
        $TITLE = 'Web-QA'
        $SEARCHURL = ('http://Search-QA.'+$domain)}
        foreach ($websvc in $websvcs) { 
           write-host 'Web Applications' 
           write-host "" 
        foreach ($webapp in $websvc.WebApplications) { 
            write-host 'Webapp Name -->'$webapp.Name 
            write-host "" 
            write-host 'Site Collections' 
            write-host ""
            $app = Get-SPWebApplication $webapp
        foreach ($site in $webapp.Sites)
            { 
                write-host 'Site URL --> -->'$site.URL 
                write-host '' 
                write-host ''
                Register-SPWorkflowService –SPSite $site –WorkflowHostUri $WFURL –AllowOAuthHttp -Force
            }
        }
    }
}
Jan 6 at 7:14 PM
there may be unused vars in there as well, haven't had a chance to clean it up.
Jan 7 at 8:01 PM
Thanks for the script.
I will take a look at it over the next few days.