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.
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
I updated from 11. x to 12.x using update-module command
And you are sure there are no folders left from a pre-6.5.1 PowerCLI version?
What does the following show?
$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
And what is in your $env:PSModulePath?
Does the following work?
$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
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
I rewrote the code to get i working.
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
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.
I have replaced my management server since then - so It's not the same installation.
Ok, I see.
Could be useful to completely remove PowerCLI from the problematic server.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Just rebooted the server - ran my module cleanup script and the it worked - strange.
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
Thanks, nice to know.