Skip to content

Author: Rafael Moura

How to create Virtual Machines from CSV with PowerCLI on VMware

Whenever it’s possible I like to automate whatever I can to release myself for other activities and save a huge time that would be wasted on repeatable or time-consuming tasks.

I have been using pieces of the following script for a long time, in a “manual automation” way, let’s say. Getting blocks and loops of scripts and creating and configuring virtual machines as needed.

In the last month I put together in a way that can be shared, and even if you don’t have much experience with powershell, you can still make use of it. šŸ™‚

Prerequisites

Install PowerCLI Module

The offline installation is available here.

Virtual Machine Template

Create a virtual machine template to be used as a base image for the deployment. No special requirements here, create accordingly to your environment.

VM Customization Specifications

Create two virtual machine customization specifications on vCenter (Linux and Windows). The only requirement is to set DNS under network section for the Linux, otherwise you might have issues after the deployment within the guest os.

CSV File

That’s the source file with all virtual machine details. There must be certain columns with specific values. These values are shown below:

  • Name
  • vCPU
  • vRAM
  • vNetwork
  • vDisk2 ..N
  • IP
  • Subnet
  • Gateway
  • Datastore
  • VMFolder
  • Specs
  • Template
  • Notes
  • OSType
  • Dns1
  • Dns2

You can download an example spreadsheet in the link below.

Each line will be specific to a virtual machine. That’s how the loop will read and create/configure accordingly.

vDisks columns can be increased as many required (vDisk2, vDisk3, vDisk4, etc.). For those VMs which doens’t use the additional disks, put “0” where not required. It starts at vDisk2 to be easily identified later, as vDisk1 will be the OSDisk from template. The vDisk format can be also changed, line 63 in the script.

The OSType value should be either “Windows” or “Linux“, that’s just a condition in order to properly run the VM creation per GuestOS.

Running the script it will always prompt for the CSV file, insert the full path location.

The next step will prompt vCenter credentials, once confirmed it won’t be prompted again if you run the script on the same powershell session.

The script then starts to read each value and deploy the VMs accordingly:

After initial deployment, the script will configure the VMs, in that section custom settings are configured, like vCPU, vRAM, vNetwork, etc.

At the end you should see a message of deployment complete and the VMs will be powered on, and probably customization specifications will be running. After that the virtual machines will be ready for use and fully customized.

Check the full script below, save as *.ps1 and use Powershell ISE or Powershell to run.

Enjoy šŸ™‚

9 Comments

Quick-Tip: How to reinstall Windows 10 Calculator after VMware OSOT

Couple weeks ago I faced an issue with a client where many users from a Horizon dedicated pool were complaining about not being able to open the Calculator in Windows 10.

Well, that’s simple right? VMware OSOT removed it during the optimization process as it wasn’t selected as a exception. It should be easy reinstalling, if you ever worked with Appx Packages in Windows 10 you know that’s not true. šŸ™‚

I knew a couple solutions, like reinstalling from the Microsoft Store, using PowerShell with AppxPackage and AppxProvisionedPackage commands, even with DISM. No luck.

I google it and couldn’t find any solution that works for me in that case. After validating many things and doing some tests, I found a solution. As I didn’t find that around, have made this post.

What happened was the Appx installation files and its dependencies were not present on that desktop anymore. Needing to be registered again and them reinstalled, also some permissions required to do that.

First of all you gonna need a brand new Windows 10, it is better at the same patch level as your problematic desktop, however it works with newer versions.

  1. Navigate to C:\Program Files\ and take the ownership of WindowsApps folder (C:\Program Files\WindowsApps), with an administrative account.
  2. On that WindowsApps folder add the permission “Full Control” to the group “All Application Packages”, also select “Replace all Child Objects”.
  3. Copy the following sub-folders from WindowsApps. The versions might be different as it depends on windows update and patch level.
    • Microsoft.WindowsCalculator_10.1812.10048.0_x64__8wekyb3d8bbwe
    • Microsoft.WindowsCalculator_10.1812.10048.0_neutral_split.scale-100_8wekyb3d8bbwe
    • Microsoft.UI.Xaml.2.0_2.1810.18004.0_x64__8wekyb3d8bbwe
    • Microsoft.VCLibs.140.00_14.0.29231.0_x64__8wekyb3d8bbwe
  4. Reinstall the dependencies, with the following commands:
    • Add-AppxPackage -registerĀ “C:\Program Files\WindowsApps\Microsoft.VCLibs.140.00_14.0.29231.0_x64__8wekyb3d8bbwe\AppxManifest.xml”Ā -DisableDevelopmentMode
    • Add-AppxPackage -registerĀ “C:\Program Files\WindowsApps\Microsoft.UI.Xaml.2.0_2.1810.18004.0_x64__8wekyb3d8bbwe\AppxManifest.xml” -DisableDevelopmentMode
  5. Reinstall the application, with the following commands:
    • Add-AppxPackage -registerĀ “C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.1812.10048.0_x64__8wekyb3d8bbwe\AppxManifest.xml”Ā -DisableDevelopmentMode
    • Add-AppxPackage -registerĀ “C:\Program Files\WindowsApps\Microsoft.WindowsCalculator_10.1812.10048.0_neutral_split.scale-100_8wekyb3d8bbwe\AppxManifest.xml”Ā -DisableDevelopmentMode

Try to open the calculator app again, it should work.

That’s it. šŸ™‚

Leave a Comment

How to Fix Horizon View Composer Upgrade error: There was an error identifying the validity of the server

Working in a client other day I had a task to update an old VMware View environment from 7.0 to 7.12, a major gap indeed. It included the upgrade of vCenter Server, Connection Server and Composer.

After upgrading the View Composer I received the following message, which is expected, as the View Composer installer will re-generate the self-signed certificate and after successfully upgraded itā€™s just required that you accept and trust the new certificate.

However that was not what happened. Right after I got another error as follows:

There was an error identifying the validity of the server.

At this point I knew that something was wrong/dirty with ADAM database, anyway did my research I found many other issues related with UPN format, wrong Composer URL, NETBIOS/FQDN issues, etc. None of that was related with my issue.

After digging down the ADAM database and validating many settings I found where was it. The issue in this case was related with the certificate thumbprint value in ADAM settings and the connection server trust with the new View Composer certificate.

The value in the composer certificate thumbprint in the ADAM database was not reflecting the new certificate, and also after that, the Connection server started to complain about View Composer certificate not trusted, and not giving any option to proceed into the Horizon Console.

So hereā€™s how I fixed the issue:

  1. Log in to the View Composer Server, open MMC/Certificates/Computer and under Personal, extract the newly generated View Composer certificate.
  2. Log in to the View Connection Server, open MMC/Certificates/Computer and under Trusted Root Certificates, import the extracted View Composer certificate previously.
  3. Now itā€™s time to enter in the ADAM database, check the following VMware KB to make the connection with ADSI Edit.
  4. Navigate to OU=Properties, OU=VirtualCenter, right-click on the CN=XXXX folder under it and select Properties.
  5. Check the pae-SVISslCertificateThumbprint attribute, change that to reflect the new View Composer self-signed certificate thumbprint.
  6. Restart the Composer and Connection Server services or servers.

At this point, navigate to Horizon Console and check the dashboard, the View Composer should be Green without any issue.

Thatā€™s it. It has been a long time since I worked with View Composer, as I couldnā€™t find the exact solution as my scenario, I made this post. šŸ™‚

Leave a Comment

How to automate VMware DEM shares configuration using PowerShell

Virtually anything can be done using PowerShell, if you have the proper time to understand the requirements, what you want to achieve and build the script. Whenever I have the opportunity I like to automate some tasks, basically to save some time and let me work on different things.

I had this script for a while, to easily configure VMware Dynamic Environment Manager during deployments and doing Lab, saving some time which could be spent on tougher and not time-consuming tasks.

I have only put together in a proper format adding some quick features to prompt the requirements.

So just run it and enjoy. šŸ˜‰

Donā€™t forget to run the script as Administrator, it can be used in any SMB/CIFS/NFS solution, which your running account has administrative privileges.

Leave a Comment

Quick-Tip: How to set root expiration in Workspace ONE Access (VMware IDM)

On all VMware appliances the accounts have a 60-day password expiration, that could meet security and operation standards in a production environment. However when doing Lab or just testing for a long-term some VMware Virtual Appliance, this tip may be usefull.

The following procedure shows how to set a different password policy for the Workspace ONE Access (formely VMware Identity Manager), but it can be used for most of VMware Appliances.

Login to your appliance, in this case WS1 Access (VMware IDM) and check the root account password policy set, running the following command:

Check the current expiration policy validating the number before last on that line, in this case 60-days:

The expiration status can also be checked, just navigate to WS1 Dashboard:

To change the expiration policy on root account for 365-days use the following command:

Check again, it should be changed for the root account and the Status on WS1 Dashboard should be green now.

That’s it! šŸ™‚

Leave a Comment

Delivering great User Experience in an EUC Project

Do it right on the first time

When an organization chooses to transition from common end-point physical computers, to Virtual Desktop Infrastructure (VDI), either on-premises or cloud-based, the IT department must do everything to minimize the risks and common issues that might happen. It is really common to architect the best possible design with an amazing hardware, a secure and reliable infrastructure, however all EUC projects at the end comes to the same point: ā€œAre the users able to use it?ā€ If you donā€™t know the answer you might not know how is the User eXperience for your clients.

The definition of User Experience (UX) is ā€œA person’s emotions and attitudes about using a particular product, system or service. It includes the practical, experiential, affective, meaningful, and valuable aspects of humanā€“computer interaction and product ownershipā€, which is basically how we interact with anything nowadays. When we open any application on a smartphone, when we use an ATM, while driving or watching YouTube, weā€™re interacting with many systems and each of them having a different user interface (UI) and also user experience (UX). The goal is to provide the best experience so that we, as users, enjoy using and without even realizing it, having them as good and reliable products.

It is not different than any EUC project, a successful project comes with a great user experience, the users will always define the project accomplishment, it doesnā€™t matter how amazing it looks like in the datacentre if the user experience is bad the users won’t buy it. To achieve a good user experience in this case, many steps and phases has to be planned, below I will list some key points to be taken in consideration in any project.

Proof of Concept

This phase is for IT department be able to test how the product and solution works, how would be integrated with the current environment, prerequisites and compatibility, and also possible to map use cases which was not yet defined. That phase usually is done as pre-sales activities.

Assessment

Every EUC project should start with a good assessment, it will give us an insight of end-user activity, to be better incorporated in the final approach. The assessment will also shows how many applications and what are most used, how is the performance of end usersā€™ machine, which can be useful to set a virtual hardware for a Pilot, and many other performance metrics to help size and design the solution.

Latency, Quality and Usability

In order to deliver the best experience for the users, the virtual desktop should have an optimized image, there are a couple tools and procedures to achieve a good result on that, VMware and Citrix have good documented steps for optimization. After that we can monitor and test the usability and quality of that image, and also not least, be very cautious with latency, which can be a huge problem and affect the user experience, if it is not right sized. Many design approaches can be used to mitigate the latency, as cloud-based VDI, geolocation access on the nearest on-premises datacentre, virtual apps, etc. It will only depend on what the use cases should be achieved.

Pilot

In this phase an approach has been set, and the use cases are known, and many tests have been performed during the POC, now itā€™s time to see how everything works together and how end-users will utilize the newly solution. Usually a few users from different areas and expertise are selected to test and use the solution.

User Expectations and Feedback

That phase is highly important, as it will dictate whatever has to be fixed, changed or aligned in order to achieve usersā€™ and project expectations. The feedback is also a great resource for the final production environment, a questionnaire should be sent together for each user, with questions regarding accessibility, usability, easiness, performance, etc.

At the end of the path we should have a good understanding of all aspects that must be considered during a EUC project, and the environment should be ready for production. It is not a difficult way, with the right tools and process everything is achievable. Always keep in mind that the user experience will dictate the value and reliability of the project and combining these key points will make the journey easier and satisfactory.

Leave a Comment