PowerShell Command Workflow: Installing the Windows File-Server Role

Create a workflow to install the Windows File Server Role

This workflow is responsible for calling the “Execute Powershell Command” workflow and executing the Install-WindowsFeature File-Server command on a Windows VM to install the File Server feature.

Create the Workflow

Create a new workflow with the name “Install-WindowsFeature File-Server.”  We are going to place this workflow in the /Examples/Tools/Scripts/Powershell One Line Commands folder.

Inputs

The workflow should have four inputs:

Input

Type

Description

vmUsername

String

Admin username for the machine that has permissions to execute a process in the operating system

vmPassword

SecureString

The password for the admin username provided in the vmUsername input

vm

VC:VirtualMachine

A reference to the virtual machine in which we want to execute a program

Figure 1. Workflow inputs for the "Install-WindowsFeature File-Server" workflow

In the workflow designer, these inputs will look as follows:

Inputs for the workflow

Figure 2. Inputs for the "Install-WindowsFeature File-Server" workflow

Attributes

We will be assigning one attribute for this workflow:

Attribute

Type

Description

Value

arguments

String

The PowerShell command to execute

“Install-WindowsFeature File-Server  -IncludeManagementTools -IncludeAllSubFeature”

Figure 3. Workflow attributes for the "Install-WindowsFeature File-Server" workflow

In the workflow designer, these will look as follows:

Attributes for the workflow

Figure 4. Attributes for the "Install-WindowsFeaure File-Server" workflow

Outputs

This workflow has one output, which is the process ID (PID) from the process being executed in the guest:

Output

Type

Description

result

Number

Process ID (PID) of the process started in guest.

Figure 5. Workflow outputs for the "Install-WindowsFeature File-Server" workflow

In the workflow designer, these inputs will look as follows:

Outputs for the workflow

Figure 6. Outputs for the "Install-WindowsFeature File-Server" workflow

Schema

The workflow consists of one step – a call to the “Execute Powershell Command” workflow we previously created.  The schema we will build will look like this:

Workflow schema

Figure 7. Workflow schema for the "Install-WindowsFeature File-Server" workflow

 

Create the Execute Powershell Command step by dragging and dropping a new “Workflow element” node on to the schema canvas between the start and end nodes.  Search for “Execute Powershell Command” to find the workflow.  Double-click it to accept it on to the canvas.

Wire the inputs, attributes, and outputs in the following manner:

  • Inputs
    • vmUsername -> vmUsername
    • vmPassword -> vmPassword
    • vm -> vm
  • Attributes
    • arguments -> arguments
  • Outputs
    • result -> result

The visual binding on the “Run program in guest” step should look as follows:

Visual binding for the Execute Powershell Command step

Figure 8. Visual binding for the "Execute Powershell Command" step in the "Install-WindowsFeature File-Server" workflow

Save the workflow and test the execution on a Windows machine in your environment.  This workflow will install the File Server feature on the windows VM you run it against.


Leave a comment