header
header Register : : Login header
header
divider
menuleft
menuright
submenu
left

[August 25th, 2008] Check the home page regarding PowerShell related news from a brand new sponsor: Idera

Can't run vmware scripts within powershell script
Last Post 26 Mar 2008 09:54 PM by bsonposh. 13 Replies.
Printer Friendly
Sort:
PrevPrev
You are not authorized to post a reply.
Author Messages
immad70User is Offline
New Member
New Member
Posts:5

--
24 Mar 2008 11:35 PM  

Hello Gurus,

I am trying to run some vmware scripts within a powershell script.  For example something like this;

script name is check_powerstate.ps1

$vcbhome="c:\program files\vmware\vmware consolidated backup framework"

$vcbhome\vcbvmname -s powerstate:on

 

I can't figure out how to run this vmware related executable file within the powershell script.  Any help would be greatly appreciated.

Andrew

 

 

halr9000User is Offline
Basic Member
Basic Member
Posts:316

--
24 Mar 2008 11:43 PM  

Andrew,

Two things:

1) It would be easier to help you out if you gave error messages or more information on what is going wrong when you try to run the below.  If I had to guess, I would think maybe you are trying to run a vbscript within powershell.  But that's beside the point because:

2) You need to go here: http://vmware.com/go/powershell and download the toolkit which just came out the other day.  Then when you need help specific to that, go to the forums dedicated to it which are here: http://communities.vmware.com/community/developer/windows_toolkit?view=discussions

Of course we're happy to help you here with more general Powershell stuff.

immad70User is Offline
New Member
New Member
Posts:5

--
25 Mar 2008 12:50 AM  
Thank you very much for the quick reply. I will make sure to check out this site and download 1st thing in the morning.
bsonposhUser is Offline
Basic Member
Basic Member
Posts:388

--
25 Mar 2008 01:04 PM  
while I WHOLE heartly agree with Hal. Download the VMWare VIToolkit.

You can try this. Assuming that vcbvmname.exe is a program.
$vcbhome="c:\program files\vmware\vmware consolidated backup framework"
invoke-expression "$vcbhome\vcbvmname.exe -s powerstate:on"
immad70User is Offline
New Member
New Member
Posts:5

--
25 Mar 2008 01:53 PM  

Hello Bsonposh,

The vcbvmname is a program that does work when invoked within the shell.  However, when invoked w/in the script it does not give any response back.

I do plan on installing the VMWare VIToolkit first opportunity.

The invoke-expression didn't work either.  I tried the following & it didn't work as well;

& "c:\program files\vmware\vmware consolidated backup\framework\vcbvmname.exe"

bsonposhUser is Offline
Basic Member
Basic Member
Posts:388

--
25 Mar 2008 02:44 PM  
That is curious. I thought perhaps the powerstate:on was the problem, but if it doesnt launch at all.

with the VI Toolkit you can do this

get-vm | ?{$_.PowerState -match "On"}
immad70User is Offline
New Member
New Member
Posts:5

--
25 Mar 2008 06:14 PM  

Thank you bsonposh,

 

Any idea on how to shut down a host with the VI Toolkit?  I can get it to go into maintenance mode, but not so sure how to shut down the host.

bsonposhUser is Offline
Basic Member
Basic Member
Posts:388

--
25 Mar 2008 07:47 PM  
I will defer to our resident expert Hal on this.

If he doesnt know a way to use VI toolkit you can use my script here http://www.powershellcentral.com/scripts/66

You can send halt or reboot.
bsonposhUser is Offline
Basic Member
Basic Member
Posts:388

--
25 Mar 2008 07:51 PM  
I assume you are the same person, but this would be for general consumption

From VMWare Community forums
----------------------------------------------
$myHost = get-vmhost
$myHostView = get-view $myHost.ID
$myHostView.RebootHost_Task($true)

http://communities.vmware.com/thread/134860?tstart=0
immad70User is Offline
New Member
New Member
Posts:5

--
26 Mar 2008 03:58 PM  

I wanted to thank everyone for your help with this.  You all were extremely helpful.

 

Thanks,
Andrew

halr9000User is Offline
Basic Member
Basic Member
Posts:316

--
26 Mar 2008 04:41 PM  

Yeah, I assumed he was the same person, too so I didn't post here. But you you know what they say about assuming... Thanks for posting that, BS.

Andrew, be sure to learn the Get-Member cmdlet. You can examine objects with it to see what methods and properties they have. You'll see that the object returned by Get-View has a TON of stuff in there. Just be careful with it in case this is your production environment. ;)

bsonposhUser is Offline
Basic Member
Basic Member
Posts:388

--
26 Mar 2008 05:27 PM  
Perhaps an example
$halPost | gm -MemberType Method
TypeName: System.hal.Post
Name MemberType Definition
---- ---------- ----------
SpellCheck Method System.hal.Post.CheckText()

$halPost.SpellCheck("Get-Veiw")

:P
halr9000User is Offline
Basic Member
Basic Member
Posts:316

--
26 Mar 2008 06:07 PM  
No clue what you are talking about. :)
bsonposhUser is Offline
Basic Member
Basic Member
Posts:388

--
26 Mar 2008 09:54 PM  
That explains alot :P
You are not authorized to post a reply.

Active Forums 4.1
right
   
footer Sponsored by Quest Software • SAPIEN Technologies • ShellTools, LLC • Microsoft Windows Server 2008 footer
footer