VMware Cloud Community
tr4x
Contributor
Contributor
Jump to solution

error running Get-VMConfigChanges

Hi,

Every time a try to run Get-VMConfigChanges I get the error:

PS C:\> Get-VMConfigChanges -vm $vm -hours 2

Exception calling "CreateCollectorForTasks" with "1" argument(s): "

Required property entity is missing from data object of type TaskFilterSpecByEntity

while parsing serialized DataObject of type vim.TaskFilterSpec.ByEntity

at line 1, column 267

while parsing property "entity" of static type TaskFilterSpecByEntity

while parsing serialized DataObject of type vim.TaskFilterSpec

at line 1, column 259

while parsing call information for method CreateCollectorForTasks

at line 1, column 171

while parsing SOAP body

at line 1, column 64

while parsing SOAP envelope

at line 1, column 0

while parsing HTTP request for method createCollector

on object of type vim.TaskManager

at line 1, column 0"

At C:\functions\Get-VMConfigChanges.ps1:72 char:5

+     $tCollector = Get-View ($taskMgr.CreateCollectorForTasks($tFilter ...

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : VimException

You cannot call a method on a null-valued expression.

At C:\functions\Get-VMConfigChanges.ps1:75 char:5

+     $tasks = $tCollector.ReadNextTasks($tasknumber)

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.

At C:\functions\Get-VMConfigChanges.ps1:107 char:5

+     $tCollector.DestroyCollector()

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

Any help?

Thank you.

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Strange, should be working like that.
Just tried, works for me.

Can you try to stop/start your PowerShell session, and do a new Connect-VIServer after the start.

Check that $global:defaultviserver is showing the VCSA as connected.

If it still doesn't work, can you attach the script you are using?

Did you dot-source the function?


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

View solution in original post

0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

I assume that you are referring to William's Get-VMConfigChanges function?

It looks like there no VirtualMachine object in your $vm variable.

Can you check, or eventually share the code with which you initialise the $vm variable


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

0 Kudos
tr4x
Contributor
Contributor
Jump to solution

Hi Luc,

thank you for answering.

Yes, i'm referring to William's Get-VMConfigChanges function.

here it is:

PS C:\> $vm = get-vm "tr-dc01"

PS C:\> $vm

Name                 PowerState Num CPUs MemoryGB   

----                 ---------- -------- --------   

TR-DC01              PoweredOn  2        4,000      

PS C:\> Get-VMConfigChanges -vm $vm -hours 2

Exception calling "CreateCollectorForTasks" with "1" argument(s): "

Required property entity is missing from data object of type TaskFilterSpecByEntity

while parsing serialized DataObject of type vim.TaskFilterSpec.ByEntity

at line 1, column 267

while parsing property "entity" of static type TaskFilterSpecByEntity

while parsing serialized DataObject of type vim.TaskFilterSpec

at line 1, column 259

while parsing call information for method CreateCollectorForTasks

at line 1, column 171

while parsing SOAP body

at line 1, column 64

while parsing SOAP envelope

at line 1, column 0

while parsing HTTP request for method createCollector

on object of type vim.TaskManager

at line 1, column 0"

At C:\Tools\scripts\functions\Get-VMConfigChanges.ps1:72 char:5

+     $tCollector = Get-View ($taskMgr.CreateCollectorForTasks($tFilter ...

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException

    + FullyQualifiedErrorId : VimException

You cannot call a method on a null-valued expression.

At C:\Tools\scripts\functions\Get-VMConfigChanges.ps1:75 char:5

+     $tasks = $tCollector.ReadNextTasks($tasknumber)

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.

At C:\Tools\scripts\functions\Get-VMConfigChanges.ps1:107 char:5

+     $tCollector.DestroyCollector()

+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

    + FullyQualifiedErrorId : InvokeMethodOnNull

referring to William's Get-VMConfigChanges function

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Strange, should be working like that.
Just tried, works for me.

Can you try to stop/start your PowerShell session, and do a new Connect-VIServer after the start.

Check that $global:defaultviserver is showing the VCSA as connected.

If it still doesn't work, can you attach the script you are using?

Did you dot-source the function?


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

0 Kudos
tr4x
Contributor
Contributor
Jump to solution

I wasn't dot-sourcing the function.

It works now.

Thank you.

0 Kudos