# PowerShell Installation

## Overview <a href="#workflowgen-setup-powershell" id="workflowgen-setup-powershell"></a>

The following procedure applies to the setup using the WorkflowGen PowerShell installation, which is only compatible with:

* Azure SQL Database&#x20;
* MS SQL Server with SQL Server authentication enabled
* Windows Server 2012 R2, Windows Server 2016, and Windows 10 x64

For other versions of Windows, use the [manual installation procedure](https://docs.workflowgen.com/tech/8.0/setup/manual-installation).

## Prerequisites

* You'll need an active internet connection to perform this installation unless all of the dependencies have been downloaded by running the script with the `-DownloadOnly` script flag.<br>
* **If you're using Azure SQL database**, you'll need to create and configure the database manually; see the [Azure SQL database configuration](https://docs.advantys.com/workflowgen-for-azure/azure-sql-database-configuration) section in the [WorkflowGen for Azure](https://docs.advantys.com/workflowgen-for-azure/) guide for instructions on how to do this.<br>
* **If you're using MS SQL Server** with the WorkflowGen database creation, the installation will require the [SQL Server PowerShell module](https://docs.microsoft.com/en-us/sql/powershell/download-sql-server-ps-module).<br>

  * **If your Windows has SQL Server and SQL Server Management Studio installed**, the SQL Server PowerShell module comes pre-installed.<br>
  * **If your Windows has PowerShell version 5 or later installed** (e.g. Windows Server 2016/Windows 10), the installation script will auto-detect and install the SQL Server module from the [PowerShell Gallery](https://www.powershellgallery.com/).<br>
  * **If your Windows has PowerShell version 4 or earlier installed** (e.g. Windows Server 2012 R2), you'll need to manually install the PowerShell Extensions from the SQL Server Feature Pack according to your SQL Server version below:

    * [SQL Server 2016 Service Pack 2 Feature Pack](https://www.microsoft.com/en-us/download/details.aspx?id=56833)
    * [SQL Server 2014 Feature Pack](https://www.microsoft.com/en-us/download/details.aspx?id=42295)
    * [SQL Server 2012 SP4 Feature Pack](https://www.microsoft.com/en-us/download/details.aspx?id=56041)<br>

    Download and install the following packages from the feature pack:

    * `ENU\x64\SQLSysClrTypes.msi`
    * `ENU\x64\SharedManagementObjects.msi`
    * `ENU\x64\PowerShellTools.msi`<br>

  ✏️ **Note:** If the PowerShell Extensions aren't available for your SQL Server version or the installation script still doesn't detect the SQL Server PowerShell module, then try installing the **PowerShell Extensions** from the SQL Server 2016 Feature Pack, or try installing **SQL Server 2016 Management Studio**.

## Important notes

* Ensure that the PowerShell Execution Policy is correctly set (see <https://technet.microsoft.com/en-us/library/ee176961.aspx>). To do this, run `Set-ExecutionPolicy Unrestricted` in the PowerShell command window.<br>

  ✏️ **Note:** If you want to avoid modifying the Execution Policy, you can bypass it by running the WorkflowGen installation script as follows: `PowerShell.exe -ExecutionPolicy Bypass -File .\install.ps1`.<br>

* Clicking on the shell while it is running will pause the output; you can change this option in the PowerShell options, or press `ENTER` to resume the output (this will not pause the script, which will continue to run in the background).<br>

* In JSON format, backslashes (`\`) must be escaped as follows:

  ```
  {
    "param" : "C:\\valid\\windows\\path"
  }
  ```

* You can abort the script at any point by pressing **`CTRL+C`**. If this is done during a download or extraction process, the folders created might need to be deleted (e.g. `\package\`); otherwise, the script will detect their presence and assume that they are complete.<br>

* The PowerShell installation will also install [Node.js v14.16.1 LTS](https://nodejs.org/download/release/v14.16.1/), [iisnode](https://github.com/Azure/iisnode/releases/tag/v0.2.21), and [IIS URL Rewrite](https://www.iis.net/downloads/microsoft/url-rewrite).\
  \
  ✏️ **Note:** [Visual C++ Redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads) is required in some particular Windows Server versions and/or configurations, otherwise you might encounter the error `The specified module could not be found` regarding the `edge` and `edge-js` libraries when accessing the `/wfgen/graphql`, `/wfgen/hooks`, or `/wfgen/scim` web apps. You'll need to download and install this manually.

* To install a previous version of WorkflowGen, use that version's PowerShell installation, available in the [Release Notes & Downloads](https://discuss.workflowgen.com/c/announcements/release-notes) section of the [WorkflowGen Forum & Knowledge Base](https://discuss.workflowgen.com/).

## Installation

1. Open `config.json` in a text editor and configure the parameters for your installation of WorkflowGen (see [PowerShell installation configuration parameters](#powershell-installation-configuration-parameters) below for information on each parameter).<br>
2. Open a PowerShell instance **as Administrator**.<br>
3. Run `.\install.ps1` (with the optional script flags listed below, if desired).

### **Optional PowerShell script flags**

| Parameter        | Description                                                                                                                                                                                                                                                                       |
| ---------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `DownloadOnly`   | <p>This option will terminate the scripts after all necessary packages have been downloaded. This is useful if you want to install WorkflowGen on a network that's not connected to the internet.</p><p>📌 <strong>Example:</strong> <code>.\install.ps1 -DownloadOnly</code></p> |
| `SkipParamInput` | <p>This option will skip the prompts to review the parameters before launching the installation script, for example if you want to run the <code>install.ps1</code> script via another script.</p><p>📌 <strong>Example:</strong> <code>.\install.ps1 -SkipParamInput</code></p>  |

### PowerShell installation configuration parameters

| Parameter                                                  | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `LicenseType`                                              | <p>Possible values: <code>trial</code> or <code>full</code> (default: <code>trial</code>)<br><br>Describes the type of license under which you're installing WorkflowGen: <code>full</code> will populate the <code>SerialNumber</code> parameter in the <code>web.config</code> file; <code>trial</code> will include the trial license (6 months).<br><br>✏️ <strong>Note:</strong> If you're installing under the full WorkflowGen license, you'll need to manually copy your license file to the WorkflowGen <code>\bin</code> folder (e.g. <code>C:\Inetpub\wwwroot\wfgen\bin</code>).</p>                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `SerialNumber`                                             | If you're installing under the full license, enter the serial number you were provided with                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `WebAppPath`                                               | The physical location where the WorkflowGen site will be located (default: `C:\Inetpub\wwwroot\wfgen`)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `ServicesPath`                                             | The physical location where the WorkflowGen services will be installed (default: `C:\Program Files\Advantys\WorkflowGen\Services`)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    |
| `NodeJSPath`                                               | The physical location where Node.js will be installed; this package is required for WorkflowGen features such as GraphQL and webhooks                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `SQLServerInstance`                                        | <p>The name or location (IP) of the SQL Server database instance<br><br>✏️ <strong>Note:</strong> If the database server is the same as the WorkflowGen application server, you can use <code>(local)</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `SQLLoginID` & `SQLPassword`                               | <p>The login credentials used exclusively for the creation of the WorkflowGen database; these must have the appropriate access level<br><br>✏️ <strong>Note:</strong> These parameters can be left empty if the <code>SQLServerInstance</code> provided already has a fully-functional (including SQL login users) and up-to-date WorkflowGen database.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `DBName`                                                   | <p>The name of the WorkflowGen database to use or create (default: <code>WFGEN</code>)<br><br>✏️ <strong>Note:</strong> If the database name is already in use, no database will be created, and the installation will assume that the database provided is fully functional (including SQL login users) and up-to-date.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `DBFilePath` & `DBLogPath`                                 | <p>The physical location where the new database will be created (only applicable when creating a new database); leaving this path empty will create the database in the default path in the environment<br><br>✏️ <strong>Note:</strong> If these parameters are specified, the identity for SQL Server must also have permission for this folder.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `DBLoginID` & `DBPassword`                                 | <p>Standard database user (with read and write permissions) used by the WorkflowGen application (default: <code>WFGEN\_USER</code>); the database user is created only if a new database is created<br><br>✏️ <strong>Notes:</strong> </p><ul><li>Make sure the <code>DBPassword</code> matches the password policy of the SQL Server when creating a new database user.</li><li>If you're creating a new database, make sure that this login is not already used (by another database, for example).</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `IISSiteName`                                              | The name of the IIS website under which the WorkflowGen application will exist; an IIS website will be created if it does not already exist (default: `WorkflowGen`)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `IISAppPoolName`                                           | The name of the IIS application pool for WorkflowGen; an application pool will be created if it does not already exist (default: `WorkflowGenAppPool`)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
| `IISBinding`                                               | <p>The IP address to be bound to WorkflowGen; the <code>*</code> value represents all unassigned IP addresses (default: <code>*</code>)<br><br>✏️ <strong>Note:</strong> This option is not supported on Windows Server 2012 R2.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |
| `IISPort`                                                  | The TCP/IP port for WorkflowGen (default: `80`)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `IISAuthentication`                                        | <p>Specifies which IIS authentication mode to use for the initial WorkflowGen installation; the possible values are <code>Windows</code>, <code>WorkflowGen</code>, and <code>Basic</code><br></p><ul><li><strong>WorkflowGen</strong> uses WorkflowGen's custom authentication module, which stores the credentials in the WorkflowGen database. If this option is selected, the initial password for the account specified in <code>WFGAdminUsername</code> will be set to <code>Passw0rd!</code> and should be changed immediately.<br></li><li><strong>Basic</strong> uses IIS authentication based on the current Windows setup. With this option, you can create a new Windows user (<code>WFGAdminUsername</code>) with a specific password, or use an existing Windows account.<br></li><li><strong>Windows</strong> uses IIS authentication based on the current Windows setup, similar to <strong>Basic</strong>; however, you'll need to be logged in as the account specified in <code>WFGAdminUsername</code>.</li></ul> |
| `WFGAdminUsername` & `WFGAdminPassword` & `WFGAdminDomain` | <p>WorkflowGen's first administrator account (default: <code>wfgen\_admin</code>); depending on the authentication method, this may require a corresponding Windows account. A password is only required if the account is being created.<br><br>✏️ <strong>Note:</strong> Make sure the <code>WFGAdminPassword</code> matches the password policy of the Windows Server when creating a new account.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |
| `WebsiteURL`                                               | The URL where WorkflowGen will be accessible; this value is populated in the `web.config` (default: `http://localhost/wfgen`)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| `SMTPServer`                                               | The location of the SMTP server for WorkflowGen; this value is populated in the `web.config` (default: `smtp.mycompany.com`)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |
| `DefaultEmailSender`                                       | The default email used as the sender for WorkflowGen notifications; this value is populated in the `web.config` (default: `workflowgen@mycompany.com`)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |
