Home » PowerCLI

Tag: PowerCLI

PowerCLI 10.0.0 - Logo

PowerCLI 10.0.0 – Error Invalid Server Certificate

Overview

On the 28 of February VMware PowerCLI 10.0.0 was released. The biggest change in this release is the multi-platform support which includes the support for Mac OS and Linux. Oh and they kind of increased the version number a bit… from 6.5.X to 10.0.0 ;).

So I decided to upgrade PowerCLI in my Lab environment. In my Lab environment I have a Windows 10 virtual machine that runs as a Administrator Workstation. The upgrade was very smooth and it took about one minute but after the upgrade no connections were possible with my vCenter server.

The following error was displayed in the PowerShell prompt, screenshots are displayed below:
Error: Invalid server certificate. Use Set-PowerCLIConfiguration to set the value for the InvalidCertificateAction option to Prompt exception for this server.

It appears that they have changed the default PowerCLI behavoir regarding certificates.

PowerCLI 6.3 – Start-VM Exception has been thrown by the target invocation.

Today I was running one of my favourite home lab scripts to startup and shutdown my lab environment. Sadly, this ended with a PowerCLI error code.

Error message:
“Start-VM Exception has been thrown by the target invocation”

Fix:
Just update PowerCLI 6.3 to PowerCLI 6.5 and all problems are gone.

Screenshots:

PowerCLI 6.3 - Start-VM Exception has been thrown by the target invocation
PowerCLI 6.3 – Start-VM Exception has been thrown by the target invocation
PowerCLI 6.5 - Start-VM problem solved
PowerCLI 6.5 – Start-VM problem solved

PowerCLI Datastore Selection without Storage DRS (SDRS)

I recently ran into the following problem: the situation occurs when you want to deploy a virtual machines with PowerCLI to a cluster with multiple datastores but your not licensed for Storage DRS.
The default PowerCLI behavior is to select the first datastore detected (alphabetic order). To solve this problem I created the following PowerCLI code:

### Variables
	$CLUSTER = "Production" 					# Cluster name
	$FOLDER = "Deployed VMs"					# Virtual Machine folder

### Select datastores available and sort them on free space (select the one with most space free)
$DS = Get-Cluster -Name $CLUSTER | Get-Datastore | Select Name, FreeSpaceGB | Sort-Object FreeSpaceGB -Descending | Select -first 1

### Create a virtual machine called VM01
New-VM -Name VM01 -ResourcePool $CLUSTER -Datastore $DS.Name -Location $FOLDER -MemoryGB 1 -CD -DiskGB 5

The code is tested with PowerCLI 6.5 R1 against a VMware vCenter 6.0 server.