There is a problem when calling "new-object VMware.Vim.ManagedObjectReference" after a reboot of the client where the VI Toolkit is instaled.
The call returns:
New-Object : Cannot find type [http://VMware.Vim.ManagedObjectReference|http://VMware.Vim.ManagedObjectReference]: make sure the assembly containing this type is loaded.
If you execute a New-Object call with any other Vim object (for example VMware.Vim.VirtualMachineConfigSpec) it works.
After this successful call the "new-object VMware.Vim.ManagedObjectReference" works as well.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
There is a problem when calling "new-object VMware.Vim.ManagedObjectReference" after a reboot of the client where the VI Toolkit is instaled.
The call returns:
</div> <pre> New-Object : Cannot find type [http://VMware.Vim.ManagedObjectReference|http://VMware.Vim.ManagedObjectReference]: make sure the assembly containing this type is loaded. </pre>
If you execute a New-Object call with any other Vim object (for example VMware.Vim.VirtualMachineConfigSpec) it works.
After this successful call the "new-object VMware.Vim.ManagedObjectReference" works as well.
The reason is that the assembly is not being automatically loaded when the PowerShell snapin is added.
One workaround is to just connect using get-viserver. Another workaround is to run:
http://Reflection.Assembly::LoadWithPartialName("vmware.vim")
I'm not sure if we can fix this (I have a feeling we can), so I'll ask.
There is a problem when calling "new-object VMware.Vim.ManagedObjectReference" after a reboot of the client where the VI Toolkit is instaled.
The call returns:
</div> <pre> New-Object : Cannot find type [http://VMware.Vim.ManagedObjectReference|http://VMware.Vim.ManagedObjectReference]: make sure the assembly containing this type is loaded. </pre>
If you execute a New-Object call with any other Vim object (for example VMware.Vim.VirtualMachineConfigSpec) it works.
After this successful call the "new-object VMware.Vim.ManagedObjectReference" works as well.
The reason is that the assembly is not being automatically loaded when the PowerShell snapin is added.
One workaround is to just connect using get-viserver. Another workaround is to run:
http://Reflection.Assembly::LoadWithPartialName("vmware.vim")
I'm not sure if we can fix this (I have a feeling we can), so I'll ask.
I tried both workarounds and neither seems to solve the problem.
1) get-viserver: in fact I have this at the start of each script. It doesn't seem to force the load
2) How do I run http://Reflection.Assembly::LoadWithPartialName("vmware.vim") in my script ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I tried both workarounds and neither seems to solve the problem.
Sorry, that formatting didn't come through right. The preview tab actually lies to you about how it will be displayed. Unbelievable.
In the code below, change < and > to their square bracket equivalents. I really wish I could figure out how to trick the forum software into displaying this properly but it's beyond my abilities.
<Reflection.Assembly>::LoadWithPartialName("vmware.vim")
That did the trick (the square brackets).
Thanks for the bypass.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference