Here is a useful PowerCLI script to collect Service Tags and Serial Numbers of the servers/blades. If you are maintaining an Inventory or gathering some information about the current hardware in your Datacenter this might be very useful to gather these information.
Run this script in your vCenter server and you will get the similar output as below. I have highlighted the serial numbers of the blades and servers in RED. In UCS you have the Chassis serial number and the blade serial number (right side) in the output.
Create a script after copying the below code and save as a .ps1 file. Execute the script and you get the service tags of your servers. You may need to add your vCenter server IP or FQDN, username and password to this script. Also if you wish to export this to a .csv file add the Exprt-csv pipeline to export to a csv file.
Three months ago VMware released VMware PowerCLI 6.5.1 with new features and you don’t need to use the old PowerCLI application to use this release. With WMware PowerCLI 6.5.1 release you can install the modules to your PowerShell though the Windows PowerShell Gallery. You can read my previous post from here.
With this release there are few improvements introduced.
Addition of the ‘InventoryLocation’ parameter to the following cmdlets: Move-VM, Import-VApp, New-VApp
Ability to mount a Content Library sourced ISO with the New-CDDrive cmdlet
Updated Support Around Experimental Features
If you have already installed the VMware PowerCLI 6.5.1 you can simply update the modules to the 6.5.2 following the below steps.
Type “Update-Module VMware.PowerCLI“, type “y” and hit enter to update the modules
It will start the module upgrade
Once it completed the upgrade check the added module using “Get-Module VMware.* -ListAvailable”
Have you ever wanted to re-configure your Virtual Machine with the up to date Virtual hardware configurations? then you should be looking for something like this. I wanted to update the Virtual network adapter to VMXNET 3 for my Virtual Machines and I could do that easily using the VMware PowerCLI.
This piece of PowerCLI command converts the Network Adapter without changing the MAC address of the adapter. If you have MAC address bind license application you don’t need to manually change the MAC Address after changing adapter.
Some of may already know that VMware has released the PowerShell 6.5.1 and there are lot’s of changes and improvements in the Modules, cmdlets and installation process. You may installed the PowerCLI as a separate component in your local management computer and used the PowerCLI cmd console to execute the commands. With this release you don’t need to worry about the separate installation for this as it comes as a PowerShell module in the PowerShell Gallery.
Here are the steps of online installation of the PowerCLI from the PowerShell Gallery.
I was trying to install this on one of our management server which was setup with Windows Server 2008 R2 SP1. It was a fresh installation and “Find-Module” command was not recognized as a PowerShell command. So I downloaded the “Windows Management Framework 5.0” from the Microsoft website and installed the update for the Windows 2008 manually.
After that, I opened a PowerShell with “Run as Administrator” and followed the below steps.
Typed the “Find-Module -Name VMware.PowerCLI” PowerShell command and it installed the NuGet Provider to download the PowerCLI modules and typed “Y” to continue the NuGet installation
Typed “Install-Module -Name VMware.PowerCLI” to install the required modules, it gave me a warning saying this is an “Untrusted Repository” typed “Y” to accept the warning.
It started the installation after that
Once it completed the installation typed “Get-Module VMware* -ListAvailable” command to view the available modules
I tried to connect to the vCenter and it was successfully connected
These steps are only for the online installation, if you have a Management computer which doesn’t have an internet connectivity you need to save them as a offline copy and need to copy to the modules folder in the Management computer.
For that followed the below steps :
Used “Save-Module -Name VMware.PowerCLI -Path C:<destination_folder> to save the modules as offline copies.
It was exported the libraries to the given folder
Checked and confirmed the libraries by typing “Get-ChildItem -Path <destination_path_of_the_libraries”>
Checked the folder path manually and folders were there
Copied these folders to the location which you can see after executing the “$ENV.PSModulePath” command
Create a Desktop Shortcut for the PowerCLI console
Most of VMware users want to keep the PowerCLI launch shortcut in their desktops. It was the practice for the later versions of the PowerCLI. Here you have to create a Shortcut manually in your desktop.
In the start menu search the PowerCLI and Create a generic x64 shortcut in your desktop
Name it as “PowerCLI 6.5.1”
Right-Clicked on the Shortcut and selected the properties of the PowerCli shortcut, added the below attributes