nirvy
Commander
Commander

Store output from vmtoolsd.exe as variable

Hi All

What i'm trying to do I thought was fairly simple, but is turning into a bit of a nightmare.

I figured this command would do what I wanted - that is retrieve a guestinfo parameter into a variable, but instead it returns nothing

PS C:\> $ToolsDaemonPath = "C:\Program Files\VMware\VMware Tools\vmtoolsd.exe"
PS C:\> $MoRef = & $ToolsDaemonPath --cmd "info-get guestinfo.MoRef"
PS C:\> $MoRef
PS C:\>

Unfortunately the output is not stored in the variable, but if I run it like this I get an output:

PS C:\> $ToolsDaemonPath = "C:\Program Files\VMware\VMware Tools\vmtoolsd.exe"
PS C:\> & $ToolsDaemonPath --cmd "info-get guestinfo.MoRef"
vm-180
PS C:\>

Any ideas?

Thanks

Mark

0 Kudos
2 Replies
nirvy
Commander
Commander

Nevermind - Figured out a way that works!

$MoRef = & $ToolsDaemonPath --cmd "info-get guestinfo.MoRef" | Out-String
0 Kudos
hisham1989
Contributor
Contributor

while executing the command for MoRef show error message "no value found"

While executing the script given by you in powershell the output string leth is zero

Please help me to get the MoRef inside the VM

0 Kudos