Archives

powershell

Citrix recently announced preview support for Azure Managed Disks in Citrix Cloud’s XenApp and XenDesktop service. Today, we are pleased to announce the release of the production version. Managed Disks provides scalable and highly available storage without the need …

What does it do?

I’ve always found the way operating systems evolve and adapt to be fascinating. They have more functionality with every release, their inner workings are more intelligent, they can automatically adapt to different situations, and are generally …

What does it do?

I’ve always found the way operating systems evolve and adapt to be fascinating. They have more functionality with every release, their inner workings are more intelligent, they can automatically adapt to different situations, and are generally …

Today I am pleased to announce support in Citrix Studio for provisioning XenApp and XenDesktop workloads into existing Azure resource groups. Until now, this popular “bring your own resource groups (BYO RG)” capability was available only via PowerShell as was

So, I promised you a part 2 in this series. This time, I want to deep-dive more into real-world usable PowerShell (PoSh) code. I will show you how my “framework” around XenMobile scripts work, and provide a link to scripts …

When PowerCLI was converted to modules, it introduced the ability to pick and choose which modules are loaded. Taking it a step further, it also allowed users to specify which versions of those modules are loaded. Historically, PowerCLI was released as one large &#lsquo;bundle&#rsquo; of modules, and was not a great release practice. This meant that even though most modules were not touched, we were still required to go through our release processes to get them out the door. This is not scalable when trying to get features to you more frequently.

With modules in the Powershell Gallery, we can now release individual modules asynchronously from other modules. The first release to really take advantage of that is PowerCLI 6.5.2. For those whom have already updated their VMware.PowerCLI module from the Microsoft PowerShell Gallery, you noticed there were only 3 modules which were updated and needed to be downloaded.

The Better Way

In prior releases, we could use the &#lsquo;Get-PowerCLIVersion&#rsquo; cmdlet and receive a high-level look at the overall PowerCLI version which was installed. Previously, our versioning scheme was not supported in PowerShell, so it took a cmdlet to print the version out (Example: VMware PowerCLI 6.5 R1). That is gone now. We&#rsquo;ve made the change to semantic versioning in 6.5.1. This means there will be no more R1, R2, or R3 releases!

Starting with PowerCLI 6.5.2, the process to get module versions has changed. Running the &#lsquo;Get-PowerCLIVersion&#rsquo; cmdlet now results in a warning message indicating that it is deprecated and to use the &#lsquo;Get-Module&#rsquo; cmdlet instead.

Using Get-Module

There are a couple ways to use the &#lsquo;Get-Module&#rsquo; cmdlet to help us determine our versioning. The reason for that is because the &#lsquo;Get-Module&#rsquo; cmdlet only shows the modules which have been imported.

The first way is to get the overall PowerCLI version, which is dependent on the &#lsquo;VMware.PowerCLI&#rsquo; module. We can determine the version by first importing the module (if it&#rsquo;s not already imported) and then running the following command:Get-Module -Name VMware.PowerCLI | Select-Object -Property Name,Version

From the above example, we can see that we&#rsquo;re using PowerCLI version 6.5.2.

Another way is to just reference the modules which have been loaded automatically. I have an example where we connect to our vCenter Server and then run the following command to find the versions of all the PowerCLI modules which are in-use:Get-Module -Name VMware.* | Select-Object -Property Name,Version

From the above example, we see that we&#rsquo;re only using a single PowerCLI module and it happens to be versioned at 6.5.2.

Running a couple additional, random, commands, we re-run the above command and see there&#rsquo;s now a bit more of a mix amongst our loaded modules.

Summary

The new method to obtain what version of PowerCLI you’re using is through the ‘Get-Module’ cmdlet. This update was made for many reasons. This new method takes advantage of how our the PowerCLI modules can be loaded independently of each other on an as needed basis. It also takes advantage of how the PowerCLI module releases can now be done asynchronously from each other. Lastly, since we’ve changed the PowerCLI versioning over to align with the standard PowerShell versioning, there&#rsquo;s no need for a custom cmdlet anymore!

If you’re using ‘Get-PowerCLIVersion’ in your scripts or modules, make sure you’re aware of this and update your resources to reflect this change!

The post What PowerCLI Version Am I On Anyways? appeared first on VMware PowerCLI Blog.

However, if you happen to have run into the following error it&#rsquo;s possible that PowerCLI was installed by the offline method:Update-Module : Module &#lsquo;VMware.PowerCLI&#rsquo; was not installed by using Install-Module, so it cannot be updated.

There&#rsquo;s two main ways to resolve this:Option 1. Remove the PowerCLI modules from where they currently reside1a. Run the following command:Get-Module VMware.* -ListAvailable1b. There should be a &#lsquo;Directory&#rsquo; label at the top of the response. Browse to that directory and remove all the directories starting with &#lsquo;VMware.*&#rsquo;

Option 2. Use the force… And by that, I mean perform the Install-Module command with the &#lsquo;Force&#rsquo; parameter2a. Perform the following command: Install-Module -Name VMware.PowerCLI -Scope CurrentUser -Force

Updating from PowerCLI 6.5.1, Offline

This process will work exactly the same as the installation process.

1. From a computer that has internet access, run the following command:Save-Module -Name VMware.PowerCLI -Path C:PathToDesiredFolder2. Take the downloaded modules and make them available to the offline system3. Copy and replace the individual PowerCLI module folders to the location where the prior modules were placed.

Updating from PowerCLI 6.5 R1 or prior releases

If you happen to be running an older version of PowerCLI which involved an MSI installer, we can verify that by running the following command:Get-Module VMware* -ListAvailable

If the majority of PowerCLI modules are versions listed at 6.5.0 or older, as shown above, proceed through the following steps.

PowerCLI 6.5 R1 (or older) Uninstallation Steps:1. Uninstall PowerCLI through the Control Panel2. Browse to the following directory: C:Program Files (x86)VMwareInfrastructure3. If there is a &#lsquo;vSphere PowerCLI&#rsquo; directory, delete it

PowerCLI 6.5.2 Online InstallationThis works exactly the same as how the installation did for PowerCLI 6.5.1.

Within a PowerShell session, type the following command: $PSVersionTable

If the PSVersion is a Value of 5.0 or above:1. Run the following command:Install-Module -Name VMware.PowerCLI –Scope CurrentUser2. If asked to update &#lsquo;NuGet Provider&#rsquo;, choose &#lsquo;Y&#rsquo; to install and import the newer version.3. If asked to &#lsquo;install modules from an untrusted repository&#rsquo;, choose &#lsquo;Y&#rsquo; to accept.

If the PSVersion is a Value of 4.x or 3.x:1. Install a current version of PowerShellGet through one of the following two options:1a. Install Windows Management Framework 5.11b. Install PackageManagement PowerShell Modules2. Run the following command:Install-Module -Name VMware.PowerCLI –Scope CurrentUser3. If asked to update &#lsquo;NuGet Provider&#rsquo;, choose &#lsquo;Y&#rsquo; to install and import the newer version.4. If asked to &#lsquo;install modules from an untrusted repository&#rsquo;, choose &#lsquo;Y&#rsquo; to accept.

PowerCLI 6.5.2 Offline Installation1. From a computer that has internet access, run the following command:Save-Module -Name VMware.PowerCLI -Path C:PathToDesiredFolder2. Take the downloaded modules and make them available to the offline system3. Copy and replace the individual PowerCLI module folders to one of the following locations:3a. Local User Usage: $homeDocumentsWindowsPowerShellModules3b. All User Usage: $pshomeModules

The PowerCLI Installation Walkthrough Video also works in this scenario too. However, following the instructions in the video will now result in PowerCLI 6.5.2 being installed:

The post Updating PowerCLI through the PowerShell Gallery appeared first on VMware PowerCLI Blog.