VMware Cloud Community
JoergenKaare
Contributor
Contributor

Changes in powercli?

Hi old scripts does not work after upgrading to latest version.

$vmname = <vm>

$cluster = Get-cluster -vm $vmname

has worked so far - but in latest version it retruns error:

get-cluster : 28-04-2020 10:33:04 Get-Cluster Value cannot be null.

Parameter name: collection

Changing to

$cluster = Get-vm $vmname | get-cluster

works.

Same thing observed for Remove-vm command.

Reply
0 Kudos
14 Replies
LucD
Leadership
Leadership

That type of error has been seen before.

Most of the time it indicates an incorrect installation.

From which PowerCLI version did you upgrade?
And to which version?

Did you follow the steps in Welcome PowerCLI to the PowerShell Gallery – Install Process Updates and more particularly in Updating PowerCLI through the PowerShell Gallery?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
JoergenKaare
Contributor
Contributor

I updated from 11. x to 12.x using update-module command

Reply
0 Kudos
LucD
Leadership
Leadership

And you are sure there are no folders left from a pre-6.5.1 PowerCLI version?

What does the following show?

Get-Module -Name VMware* -ListAvailable

$env:PSModulePath


As an ultimate procedure, perhaps remove all PowerCLI related folders and do the Install-Module once more.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
JoergenKaare
Contributor
Contributor

Capture.JPG

Reply
0 Kudos
LucD
Leadership
Leadership

And what is in your $env:PSModulePath?

Does the following work?

$vmname = <vm>

$cluster = Get-cluster -Name * -VM $vmname

This was a working bypass in Re: Get-VM Error after PowerCLI Upgrade


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
LucD
Leadership
Leadership

Btw, I just noticed that you had a similar problem already in PowerCLI 6.5.3

Re: new-tagassignment value cannot be null

Was that ever solved (not using the bypass)?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
JoergenKaare
Contributor
Contributor

I rewrote the code to get i working.

Reply
0 Kudos
LucD
Leadership
Leadership

So a similar problem was already present when you migrated to 6.5.3?

Did you try the -Name * test I posted earlier?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
JoergenKaare
Contributor
Contributor

Seems to be problem on a seperate server - just tested on a server running 11.5 - works - and on another also running 12. 0 - works, so I'll invesitage why this is a local problem just on one installation.

Reply
0 Kudos
JoergenKaare
Contributor
Contributor

I have replaced my management server since then - so It's not the same installation.

Reply
0 Kudos
LucD
Leadership
Leadership

Ok, I see.

Could be useful to completely remove PowerCLI from the problematic server.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
JoergenKaare
Contributor
Contributor

Just rebooted the server - ran my module cleanup script and the it worked - strange.

Reply
0 Kudos
LucD
Leadership
Leadership

That "Value cannot be null" error often points to a botched install or somehow corrupted environment.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
JoergenKaare
Contributor
Contributor

Thanks, nice to know.

Reply
0 Kudos