...now browsing by category


Check MAC addresses for all VMs

piątek, Luty 15th, 2013

A quicker – how to check MAC addresses assigned to all VMs:

Get-VM | Select-Object -Property Name,@{N=”MacAdresses”;E={$_.NetworkAdapters | ForEach-Object {$_.MacAddress}}},VMHost

The script found here. After a small modification it can show MACs for VMs in a resource pool, VMs filtered by name, etc.

PowerCLI po polsku! czyli nowa inicjatywa Grzegorza Kulikowskiego

wtorek, Listopad 27th, 2012

Ruszyła strona powerclipopolsku.info, gdzie Grzesiek Kulikowski rozpowszechnia wiedzę o Powershellu w ogólności i PowerCLI w szczególności oraz zaprasza chętnych do współpracy. Więcej info na stronie i na linkedinowym PLVMUG.

Veeam error „Object VM_name not found”: on vSphere object IDs.

środa, Październik 3rd, 2012

I like problems. While solving them we can always learn something new and extend our knowledge. Today’s problem symptoms in Veeam’s failed job are as follows:

Can't process object "VM name".
Object "VM name" not found.

This means that VMs have been probably removed from inventory or the host has been removed from vCenter and then readded. This operation changes the ID of the VM and Veeam stops recognizing it. We are not talking about BIOS UUID written in vmx but rather about Managed Object Reference ID, the identificator inside vCenter „reality”, generated for new objects by vSphere when objects, like VMs, are created. Before fixing Veeam let’s have a look on different identifiers in vSphere / on ESXi.

These are three different IDs we can have:

1 .BIOS UUID – written in vmx file, it is not guaranteed to be unique.

2. instanceUuid – introduced in the vSphere 4.0 API to resolve problems with ununique BIOS UUID.

This a part of vmx file:

A part of vmx file
A part of vmx file

In this file we can see two identifiers – uuid.bios (BIOS UUDI) and vc.uuid (instanceUUID). I could not find any information in VMware documentation that vc.uuid is the same as instanceUUID but it can be confirmed with this Pearl script:

Finding instanceUUID
Finding instanceUUID

3. Managed Object Reference ID (MoRef ID) – as mentioned before this is an ID for use in vSphere.

We can check it with the same Pearl script as before or simply withPowerCLI:

Checking VM's MoRef ID
Checking VM’s MoRef ID

Now I will remove the machine from the inventory:

Unregistering VM
Unregistering VM

When I readd it and check the ID, it is different:

Modified MoRef ID
Modified MoRef ID

This is the ID that is used by Veeam Backup & Replication 4. It does not happen often to remove a VM from inventory or remove host with this VM running from vCenter. But when it happens it will break the backup job.

Here is a solution to the problem in Veeam 6 that applies manual change to Veeam database.

I found a fix suggested by this KB much easier. It was enough to edit properties for the job, remove VM and readd it. The backup file remains the same (it is greyed out and it cannot be modified anyway). My only concern was if the backup is not started from the scratch. I run a modified job on a test server and sure enough the restore was possible from the backups before the last one.


Uniquely Identifying Virtual Machines in vSphere and vCloud: Part 1 and Part 2

VMware vSphere 5.1 Documentation Center – Virtual Machine Identification

A quick PowerCLI to check for mounted physical CD

niedziela, Maj 6th, 2012

If you want to check all your VMs for mounted phsical CDs, here it goes:
foreach ($dc in $datacenters)
$vms = get-datacenter -name $dc | get-vm
foreach($vm in $vms)
if(get-cddrive -VM $vm | where {$_.HOSTPATH -ne $null})
write-host $vm.name
write-host $vm.vmhost
write-host $dc.Name
write-host „”

So you wanna learn PowerCLI? – Part 1: PowerCLI overview

piątek, Grudzień 16th, 2011

PowerCLI is an extremely powerful (hence the name ;-) way of managing your VMware infrastructure. It is a set of additional cmdlets for MS PowerShell that extend PS to managing VMware environment. Please explore Microsoft resources if you would like to know more about PowerShell itself – how to install it, how to run it, etc. Here I’ll assume you have your PS already installed and you know how to open it ;-) You can probably run a script downloaded from the Internet or copied from a site but if you’d like to see how PowerCLI works and how to write your own scripts – this place is right for you. If you manage a significant number on VMs on even a few hosts believe me, there will be situations when PowerCLI will save a lot of time for you.

Let’s start with VMware PowerCLI site where you can find both PowerCLI for download and huge amount of information – from ready scripts to discussions to white papers and posters. The installer is about 90MB in size – go and grab it. The instalation itself is pretty straightforwad and consists in clicking Next. The only thing that can suprise you might be the following window:





So what as just happened? Basically the installer tells you that the script launch policy on your computer might make running downloaded scripts, or any scripts in fact,  impossible. Click Continue button and go ahead with the installation. When PowerCLI is being installed on your computer, open PowerShell and put the following command:


You may get as a response „Restricted”. Aha! So this is what the warning was talking about. Basically in PowerShell you can set your script execution policy to 4 different levels. It will influence your ability to run different scripts:

Restricted - No scripts can be run. Windows PowerShell can be used only in interactive mode.
AllSigned - Only scripts signed by a trusted publisher can be run.
RemoteSigned - Downloaded scripts must be signed by a trusted publisher before they can be run.
Unrestricted – No restrictions; all Windows PowerShell scripts can be run.
[info via http://technet.microsoft.com/en-us/library/ee176847.aspx]

You can change it with Set-ExecutionPolicy cmdlet followed with the level appropriate for you. More information can be found directly in PowerShell via Get-Help about_signing cmdlet.

By this time PowerCLI should be already installed. Take your time and look for it under VMware > VMware vSphere PowerCLI in your start menu. Got it? Good.

In order to do anything useful we need first to connect to the server. What server? It can be both your ESX/ESXi host and vCenter Server. You do it with one command:


When you hit enter PowerCLI is oing to ask you for the server’s address or name, login and password. You can pass all these parameters at the same time:

Connect-VIServer -server [Your_server_IP] -user [Your_username] -password [Yeap_your_password_here]

Now, once connected to the server we can unleash the whole power of PowerCLI. Next time we will see how to find useful cmdlets, how to learn about them and how to pass the information from one cmdlet to another. Execute the following command


to disconnect your PowerCLI. Stay tuned for a next part.

PowerShell in SCVMM 2008 R2 – Part 2: Guest OS Profile

poniedziałek, Kwiecień 4th, 2011

In my last note we saw how easily hardware profiles can be generated using PowerShell Snapin and its cmdlets for SCVMM 2008 R2. Now it is time to have a closer look on Guest OS Profiles that we will use later to create templates and deploy new VMs. Click to continue »

Managing Hyper-V with PowerShell without SCVMM

niedziela, Kwiecień 3rd, 2011

For those who want to manage Hyper-V host and VMs with PowerShell but do not have SCVMM installed, I have a good news: on this page you will find a management library for Hyper-V. If you are missing cmdlets like Add-VM or Get-VHDInfo, search no more. It supports enormous set of cmdlets every Hyper-V administrator will find useful. Really cool!

When you download it, make sure you set ExecutionPolicy correctly as the scripts are not signed. The downloads can be found here – make sure you read the documentation first.

Why such cmdlets were not included in Windows Server 2008 – the answer is: time. In WS 2008 RTM Hyper-V was not even included and at this time it was in beta. Why these cmdlets were not included in Windows Server 2008 Rs? The answer is: I dunno. I don’t believe MS intended to sell more SCVMM with an argument that it supports PS for Hyper-V. But I definitely want to see it in next WS release or as an update to R2.

PowerShell in SCVMM 2008 R2 – Part 1

wtorek, Marzec 29th, 2011

Microsoft PowerShell is a great way to automate activities related to VM creation, maintenance and management. Here’s a simple way to create a new hardware profile for SCVMM 2008. Click to continue »