VMware Cloud Community
binoche
VMware Employee
VMware Employee

Invoke-VMScript but "Object reference not set to an instance of an object."?

Hi experts,

I want to use invoke-vmscript to operate Win2K8R2 guest vm from powercli but hit only "Invoke-VMScript        Object reference not set to an instance of an object.",

I have Test-InvokeVMScript from LucD http://www.lucd.info/2012/01/01/will-invoke-vmscript-work/ to check my Win2K8R2 guest vm and it reported "X86Engine:False",

do you know what I was missing and how to let invoke-vmscript works? thanks in advance

PowerCLI C:\..\vSphere PowerCLI> $vm=get-vm|where {$_.name -eq "pvscsi-win2k8"}

PowerCLI C:\..\vSphere PowerCLI> $vm

Name                 PowerState Num CPUs MemoryGB

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

pvscsi-win2k8        PoweredOn  1        4.000

PowerCLI C:\..\vSphere PowerCLI> Test-InvokeVMScript -VM $vm -Detail

Exception calling "GetVersionInfo" with "1" argument(s): "C:\Program Files\VMware\VMware VIX\VixCOM.dll"

At line:102 char:73

+     $propertiesVix =[System.Diagnostics.FileVersionInfo]::GetVersionInfo <<<< ($env:programfiles + '\VMware\VMware VI

X\VixCOM.dll')

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

    + FullyQualifiedErrorId : DotNetMethodException

OK                          : False

VM                          : pvscsi-win2k8

PoweredOn                   : True

X86Engine                   : False

ToolsInstalled              : True

Port902Open                 : True

FolderReadAccess            : True

PrivilegeConsoleInteraction : True

SupportedOS                 : True

PowerCLI C:\..\vSphere PowerCLI> Invoke-VMScript -VM $vm -ScriptText "dir" -GuestUser Administrator -GuestPassword password -ScriptType BAT

Invoke-VMScript : 11/17/2013 9:46:38 PM    Invoke-VMScript        Object reference not set to an instance of an object.

At line:1 char:16

+ Invoke-VMScript <<<<  -VM $vm -ScriptText "dir" -GuestUser Administrator -GuestPassword password -ScriptType BAT

    + CategoryInfo          : NotSpecified: (:) [Invoke-VMScript], ViError

    + FullyQualifiedErrorId : Client20_VmGuestServiceImpl_TryGetGuestProcessManager_ViError,VMware.VimAutomation.ViCor

   e.Cmdlets.Commands.InvokeVmScript

PowerCLI C:\..\vSphere PowerCLI>

Tags (1)
Reply
0 Kudos
3 Replies
LucD
Leadership
Leadership

You are calling Invoke-VMScript from a 64-bit session it seems.

Start the 32-bit PowerCLI version and try from there


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

Reply
0 Kudos
binoche
VMware Employee
VMware Employee

thanks Sir, I had tried with 32-bit PowerCLI but still did not work, then I switched to powershell remoting invoke-command, it works

Reply
0 Kudos
LucD
Leadership
Leadership

Great, but that requires the guest OS to be reachable over the network.

The Invoke-VMScript works through the vSphere server - VM connection and uses the VMware Tools to run your commands/script inside the guest OS.


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

Reply
0 Kudos