One of the benefits of MED-V 2 was the introduction of PowerShell to control, manage, and deploy the MED-V workspace. A good example of where PowerShell comes in handy is when you have a workspace that you have already configured and packaged – but now you need to make an adjustment to the configuration for future deployments of that workspace. A walkthrough of how to do this is as follows:
- Navigate to the directory where the workspace package was created.
- After making a backup of this directory, notice that you have both a .REG file and a .PS1 file. The .REG file contains the basic configuration. You can use the PS1 file to set advanced settings an regenerate the MED-V workspace.
- Open the .PS1 file in the integrated script editor. You will notice it looks like the script below:
import-module -Name "Microsoft.Medv"
$regFileInfo = New-MedvConfiguration -VmNetworkingMode "BRIDGED" -UxLogonStartEnabled "False" -UxCredentialCacheEnabled "True" -FtsMode "Attended" -VmMultiUserEnabled "False" -FtsAddUserToAdminGroupEnabled "True" -FtsStartDialogMsg "A virtual environment is being created for application compatibility. The first time setup process can take several minutes to complete." -FtsFailureDialogMsg "First time setup failed while creating a virtual environment for application compatibility." -FtsRetryDialogMsg "First time setup failed while creating a virtual environment for application compatibility." -FtsSetUserDataEnabled "True" -FtsSetJoinDomainEnabled "True" | Export-MedvConfiguration -Path "C:\medv2-packages\Windows XP Compatibility.reg" -PassThru
if ($regFileInfo) #If the .Reg file was created, then create the workspace package
New-MedvWorkspace -WorkspaceName "Windows XP Compatibility" -VhdFilePath "C:\vpc\Medv-ws-xp.vhd" -SettingsFilePath "C:\medv2-packages\Windows XP Compatibility.reg" -VhdRegPath "C:\Program Files\Microsoft Enterprise Desktop Virtualization\MEDV_InternetZoneHighSecurity.reg,C:\Program Files\Microsoft Enterprise Desktop Virtualization\MEDV_RestrictedBrowsingMode_Apply.reg" | Export-MedvWorkspace -Path "C:\medv2-packages\Windows XP Compatibility.msi" -Overwrite
Let’s say you wanted to adjust the FtsAddUserToAdminGroupEnabled option and set it to “false.” You could simply make the adjustment in the .PS1 file and repackage the workspace.
You could even add in additional advanced options (Boolean.) For example, if you wanted to disable host guest network printer sharing, you could add an additional parameter to the script to add the –UxPrinterSharingEnabled parameter and set it to “False.” Once you have made the changes, save the new .PS1 file and close the Powershell ISE. By the way, you can use the WMI reference for additional options:
Repackaging a Workspace Using PowerShell.
If you are doing this customization, you will need to re-package the workspace using the PS1 file.
- Open a PowerShell command prompt as Administrator.
- Change to the current directory of the of the workspace package.
- Execute the PS1 file. This will start the process of creating the workspace package with these customized settings. Once the packaging process is complete you can deploy the newly created setup, MSI and workspace package.