We can automate the typical "administrator" tasks associated with initializing, naming, drive letter assignment and disk formatting; using a completion workflow. There are two methodologies to consider:
1. Fully automated (requires no interaction with the requester)
2. User-defined (user interaction required)
Step 1: Setting up the Change Request Form
Start by configuring a new change request form for the addition of a new disk.
1. In the vCommander admin console, select Configuration > Service Request Configuration > Form Designer
2. Select "Add"
3. Name the new form "Add New Disk" and set the form type to "Change Request Form"
4. Assign an organization or publish the form globally then press "OK"
** We will be adding a completion workflow to this form after we've completed it.
5. Select Storage from the toolbox and add it to the new form. Configure the storage tool to only have the "Add" action
6. Press "Save" to complete the form creation
Step 2 - Setting up the Completion Workflow
Method 1 - Fully Automated Disk Initialization
This methodology will automatically assign a drive letter, name, and format the new disk as GPT.
Setting up the Completion Workflow
1. From the vCommander admin console, select Configuration > Service Request Configuration > Completion Workflow
2. Select "Add"
3. Name the new workflow "Add New Disk"
4. Select Apply This Workflow: "After aChange Request is Fulfilled" then select "Next"
5. Add a "Create File" step under the Guest OS option with the following parameters:
Step Name: Create File
Step Execution: Always Execute
When Step Fails: Mark Workflow step as failed: do not proceed
Credentials: select credentials that have administrative rights to the target guest operating system
Contents:
Get-Disk | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle GPT -PassThru | New-Partition -AssignDriveLetter -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel "New Disk" -Confirm:$false
Destination: C:\Scripts\NewDisk.ps1 (note the destination folder must already exist)
Overwrite: Yes
6. Add a "Run Program" step with the following parameters
Step Name: Run Program
Step Execution: Always Execute
Timeout: 300 seconds
Credentials: select credentials that have administrative rights to the target guest operating system
Program Output: Capture program output as a comment
When Program Fails: Mark Workflow step as failed: do not proceed
Command Line:
powershell.exe -ExecutionPolicy Bypass c:\Scripts\NewDisk.ps1 -Verb runAs
7. Select "Next" to proceed to the Assigned Forms page
8. Select "Apply this workflow to the selected forms" and select the "Add New Disk" form we created earlier
9. Select "Next" to proceed to the summary page and select finish
Method 2 - User Defined Disk Initialization
This methodology will allow the requester to assign a drive letter, name, and format for the new disk.
Creating the Required Custom Attributes
First, you need to create custom attributes for the disk format, disk name and drive letter.
1. From the vCommander admin console navigate to Configuration > Custom Attributes
2. Select "Add" and create the three custom attributes according to the configurations below
3. Create the Disk Format custom attribute
Name: Disk Format
Description: Format of the Disk, can be MBR or GPT
Type: List
Applies to: All Types
Edit in Service Portal: yes
Next, add attribute values MBR and GPT.
4. Create the Disk Name custom attribute
Name: Disk Name
Description: Name of the Disk as it appears in windows.
Type: Text
Applies to: All Types
Edit in Service Portal: yes
Next, configure the attribute as free form or select specific format if you wish to apply a regular expression to the naming format.
5. Create the Drive Letter custom attribute
Name: Drive Letter
Description: Drive letter as it appears in windows
Type: List
Applies to: All Types
Edit in Service Portal: yes
Next, add attribute values A-Z excluding any reserved drive letters commonly in use (as an example C:)
Updating the Form with the New Custom Attributes
1. To add your newly created attributes to the "Add New Disk" change request form, follow these steps:
Navigate to Configuration > Service Request Configuration > Form Designer and select the "Add New Disk" change request form.
2. From the Toolbox select custom attribute, using the drop-down select disk format. repeat this action for the disk name and drive letter custom attributes.
3. Press "Save" to complete the form updates
Setting up the Completion Workflow
1. We are now ready to create a completion workflow for the change request form.
From the vCommander admin console, select Configuration > Service Request Configuration > Completion Workflow
2. Select "Add"
3. Name the new workflow "Add New Disk"
4. Select Apply This Workflow: "After a Change Request is Fulfilled" then select "Next"
5. Add a "Create File" step with the following parameters:
Step Name: Create File
Step Execution: Always Execute
When Step Fails: Mark Workflow step as failed: do not proceed
Credentials: select credentials that have administrative rights to the target guest operating system
Contents:
Get-Disk | Where partitionstyle -eq 'raw' | Initialize-Disk -PartitionStyle #{target.settings.customAttribute['Disk Format']} -PassThru | New-Partition -DriveLetter #{target.settings.customAttribute['Drive Letter']} -UseMaximumSize | Format-Volume -FileSystem NTFS -NewFileSystemLabel "#{target.settings.customAttribute['Disk Name']}" -Confirm:$false
Destination: C:\Scripts\NewDisk.ps1 (note the destination folder must already exist)
Overwrite: Yes
6. Add a "Run Program" step with the following parameters
Step Name: Run Program
Step Execution: Always Execute
Timeout: 300 seconds
Credentials: select credentials that have administrative rights to the target guest operating system
When Program Fails: Mark Workflow step as failed: do not proceed
Command Line:
powershell.exe -ExecutionPolicy Bypass c:\Scripts\NewDisk.ps1 -Verb runAs
7. Select "Next" to proceed to the Assigned Forms page
8. Select "Apply this workflow to the selected forms" and select the "Add New Disk" form we created earlier
9. Select "Next" to proceed to the summary page and select finish