Discussion:
Shutdown VMWare player without VMToolkit
(too old to reply)
Ripp
2008-09-21 16:11:01 UTC
Permalink
Hi all,

I have vmware player running on a few workstations. Right now to kill
vmware player i kill the process with powershell. Is there a way to issue a
shutdown and poweroff to vmware player without the toolkit? I don't have a
vmware server.

I'm a bit new to vmware and powershell so any advice is great.

Thanks,
Ripp
Ripp
2008-09-21 21:03:00 UTC
Permalink
Okay, i found this code and was able to use it, the only problem i'm having
now is receiving the output from the command if it is possible. For example
lets say i ran a Dir command on a directory on the remote machine, how would
i get back the dir listing?

$ProcessClass = get-wmiobject -query "SELECT * FROM Meta_Class WHERE
__Class = 'Win32_Process'" -namespace "root\cimv2" -computername $computer
$results = $ProcessClass.Create($command)

Any help would be appreciated =)
Post by Ripp
Hi all,
I have vmware player running on a few workstations. Right now to kill
vmware player i kill the process with powershell. Is there a way to issue a
shutdown and poweroff to vmware player without the toolkit? I don't have a
vmware server.
I'm a bit new to vmware and powershell so any advice is great.
Thanks,
Ripp
Marco Shaw [MVP]
2008-09-22 00:23:42 UTC
Permalink
Post by Ripp
Okay, i found this code and was able to use it, the only problem i'm having
now is receiving the output from the command if it is possible. For example
lets say i ran a Dir command on a directory on the remote machine, how would
i get back the dir listing?
$ProcessClass = get-wmiobject -query "SELECT * FROM Meta_Class WHERE
__Class = 'Win32_Process'" -namespace "root\cimv2" -computername $computer
$results = $ProcessClass.Create($command)
That's the thing with WMI, you can't get any direct feedback.

You can check this out for running remote commands:
http://www.windowsnetworking.com/articles_tutorials/How-Windows-Server-2008-WinRM-WinRS.html

Above says 2008, but that will work with 2003 also. WinRM is bundled
with 2008, but can be installed manually on 2003.

Marco
--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
Ripp
2008-09-21 21:11:01 UTC
Permalink
C:\Program Files\VMware\VMware Workstation\vmrun stop c:\images\ua.vmx

What the plan is is to use the vmrun.exe which came with the player to stop
the virtual machine. I want to do "vmrun list" to get the path output to
the image, then strip that path and filename and supply it as an argument to
"vmrun stop"

example: "C:\Program Files\VMware\VMware Workstation\vmrun stop
c:\images\ua.vmx"

i have no path setup to the vmware directory to execute the vmrun.exe file
from anywhere and the image file will never be the same so i need to get the
output from the "vmrun list" to strip out the path and image file name to
pass as a parameter to "vmrun stop <path>"
Post by Ripp
Hi all,
I have vmware player running on a few workstations. Right now to kill
vmware player i kill the process with powershell. Is there a way to issue a
shutdown and poweroff to vmware player without the toolkit? I don't have a
vmware server.
I'm a bit new to vmware and powershell so any advice is great.
Thanks,
Ripp
Marco Shaw [MVP]
2008-09-22 00:40:17 UTC
Permalink
Post by Ripp
C:\Program Files\VMware\VMware Workstation\vmrun stop c:\images\ua.vmx
What the plan is is to use the vmrun.exe which came with the player to stop
the virtual machine. I want to do "vmrun list" to get the path output to
the image, then strip that path and filename and supply it as an argument to
"vmrun stop"
example: "C:\Program Files\VMware\VMware Workstation\vmrun stop
c:\images\ua.vmx"
i have no path setup to the vmware directory to execute the vmrun.exe file
from anywhere and the image file will never be the same so i need to get the
output from the "vmrun list" to strip out the path and image file name to
pass as a parameter to "vmrun stop <path>"
Sorry, I'm not following. You want to run 'vmrun list' to get a listing
of the locations of the VMX files, then use those locations and run each
as an argument to 'vmrun stop'?

If you can provide some sample output from 'vmrun list', I'm sure we can
help you to figure out how to extract the paths.

Then show us exactly how you need to invoke 'vmrun stop'.

Marco
--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
Marco Shaw [MVP]
2008-09-22 00:29:53 UTC
Permalink
Post by Ripp
Hi all,
I have vmware player running on a few workstations. Right now to kill
vmware player i kill the process with powershell. Is there a way to issue a
shutdown and poweroff to vmware player without the toolkit? I don't have a
vmware server.
I'm a bit new to vmware and powershell so any advice is great.
Thanks,
Ripp
You're trying to kill these remotely or locally? Do the VMs have their
own public IP? You could use WMI to talk directly to the VM to ask it
to shutdown.

Maybe I'm missing the point though...

Marco
--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
Ripp
2008-09-22 16:20:05 UTC
Permalink
Hi,

Sorry I wrote that up in a hurry...

What I have is several remote workstations (XP SP2) running a vmware image.
The images are started by the users during the day and should shut them down
at night. What I did is created a script that will run through all the
workstations at night and kill the vmware-vmx.exe process which kills the
session. I was thinking a better way to do this is to use "<vmrun stop
<image file>", which stops virtual server, and then kill the process to kill
VMWare player so the workstation goes back to it's startup menu.

Now in order to call the vmrun.exe and make it work properly using WMI I
have to supply the path to vmrun.exe as well as the path to the vm image
file that is running and the complete path to it. (fyi, there are several
image files on each workstation and the one running depends on what the user
selects so I will have no idea.) The command would have to be pass remotely
to the workstation using the following code. The $command will need to
contain a string like this "C:\Program Files\VMware\VMware Workstation\vmrun
stop c:\images\calif\ua.vmx"

$ProcessClass = get-wmiobject -query "SELECT * FROM Meta_Class WHERE
__Class = 'Win32_Process'" -namespace "root\cimv2" -computername $computer
$results = $ProcessClass.Create($command)

The path to the vmrun.exe file will always be the same which is no problem.
The path and image file will always be different. By using "vmrun list" on
the remote machine the command spits out the path and filename of the image
running. If somehow I could get that output back from the remote machine I
could strip out that path and image file name and pass it to the command for
the "vmrun stop" command.

I noticed you supplied a URL to look at and said WMI will not pass output
back. I will go check out that URL. If you have any other ideas to
accomplish this task please share. The kill process works great just
doesn't seem like a clean way to shutdown a vmware player that is running a
image. I know there is VMToolkit that looks like what I want but company
won't spend money on VMWare server which I believe the toolkit requires.

Thanks,
Ripp
Post by Marco Shaw [MVP]
Post by Ripp
Hi all,
I have vmware player running on a few workstations. Right now to kill
vmware player i kill the process with powershell. Is there a way to
issue a shutdown and poweroff to vmware player without the toolkit? I
don't have a vmware server.
I'm a bit new to vmware and powershell so any advice is great.
Thanks,
Ripp
You're trying to kill these remotely or locally? Do the VMs have their
own public IP? You could use WMI to talk directly to the VM to ask it to
shutdown.
Maybe I'm missing the point though...
Marco
--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
Jon
2008-09-22 14:28:37 UTC
Permalink
Post by Ripp
Hi all,
I have vmware player running on a few workstations. Right now to kill
vmware player i kill the process with powershell. Is there a way to issue a
shutdown and poweroff to vmware player without the toolkit? I don't have a
vmware server.
I'm a bit new to vmware and powershell so any advice is great.
Thanks,
Ripp
You could try using 'CloseMainWindow' rather than (presumably) the 'Kill'
method, which as its name suggests is slightly less forceful. eg

Get-Process vmplayer | foreach {$_.CloseMainWindow()}

The rest is just having the appropriate settings within vmplayer I believe.
--
Jon
Ripp
2008-09-22 19:53:38 UTC
Permalink
I don't have time at the moment to look into but is that going to work for
remote machines? I do like that idea over killing the process as well.
Post by Jon
Post by Ripp
Hi all,
I have vmware player running on a few workstations. Right now to kill
vmware player i kill the process with powershell. Is there a way to issue a
shutdown and poweroff to vmware player without the toolkit? I don't have a
vmware server.
I'm a bit new to vmware and powershell so any advice is great.
Thanks,
Ripp
You could try using 'CloseMainWindow' rather than (presumably) the 'Kill'
method, which as its name suggests is slightly less forceful. eg
Get-Process vmplayer | foreach {$_.CloseMainWindow()}
The rest is just having the appropriate settings within vmplayer I believe.
--
Jon
Jon
2008-09-23 08:03:18 UTC
Permalink
Post by Ripp
I don't have time at the moment to look into but is that going to work for
remote machines? I do like that idea over killing the process as well.
If you can get it to work locally, then it should also be possible to get it
working remotely.

I'd probably use winrm / winrs for running the necessary remote Powershell
script(s), as was suggested earlier in the thread, but there are undoubtedly
other ways.
--
Jon
Ripp
2008-09-23 12:18:05 UTC
Permalink
Okay, i got an idea about sending the wmi command line to the remote and
getting back output. What if i pipe that command to a text file on the
remote computer, can i pull that text file back and parse it? Advice?
Post by Ripp
I don't have time at the moment to look into but is that going to work for
remote machines? I do like that idea over killing the process as well.
Post by Jon
Post by Ripp
Hi all,
I have vmware player running on a few workstations. Right now to kill
vmware player i kill the process with powershell. Is there a way to issue a
shutdown and poweroff to vmware player without the toolkit? I don't have a
vmware server.
I'm a bit new to vmware and powershell so any advice is great.
Thanks,
Ripp
You could try using 'CloseMainWindow' rather than (presumably) the 'Kill'
method, which as its name suggests is slightly less forceful. eg
Get-Process vmplayer | foreach {$_.CloseMainWindow()}
The rest is just having the appropriate settings within vmplayer I believe.
--
Jon
Jon
2008-09-23 17:58:37 UTC
Permalink
Post by Ripp
Okay, i got an idea about sending the wmi command line to the remote and
getting back output. What if i pipe that command to a text file on the
remote computer, can i pull that text file back and parse it? Advice?
Yep, sounds cool. Looks like you've had some relevant tips in a more recent
thread.
--
Jon
Loading...