header1   header
header
header Register : : Login header
header
connector   connector
menuleft menuright
submenu   submenu
left
Can't run vmware scripts within powershell script
Last Post 26 Mar 2008 01:54 PM by Brandon Shell [MVP]. 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
Avatar

--
24 Mar 2008 03: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
    PowerShell MVP, Site Admin
    Advanced Member
    Advanced Member
    Posts:565
    Avatar

    --
    24 Mar 2008 03: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/commu...iscussions

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

    Community Director, PowerShellCommunity.org
    Co-host, PowerScripting Podcast
    Author, TechProsaic
    immad70User is Offline
    New Member
    New Member
    Posts:5
    Avatar

    --
    24 Mar 2008 04:50 PM
    Thank you very much for the quick reply. I will make sure to check out this site and download 1st thing in the morning.
    Brandon Shell [MVP]User is Offline
    Basic Member
    Basic Member
    Posts:396
    Avatar

    --
    25 Mar 2008 05:04 AM
    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"
    Brandon Shell
    ----------------
    Microsoft Powershell MVP
    https://mvp.support.microsoft.com/profile/Brandon
    Blog: http://www.bsonposh.com
    immad70User is Offline
    New Member
    New Member
    Posts:5
    Avatar

    --
    25 Mar 2008 05:53 AM

    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"

    Brandon Shell [MVP]User is Offline
    Basic Member
    Basic Member
    Posts:396
    Avatar

    --
    25 Mar 2008 06:44 AM
    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"}
    Brandon Shell
    ----------------
    Microsoft Powershell MVP
    https://mvp.support.microsoft.com/profile/Brandon
    Blog: http://www.bsonposh.com
    immad70User is Offline
    New Member
    New Member
    Posts:5
    Avatar

    --
    25 Mar 2008 10:14 AM

    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.

    Brandon Shell [MVP]User is Offline
    Basic Member
    Basic Member
    Posts:396
    Avatar

    --
    25 Mar 2008 11:47 AM
    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.
    Brandon Shell
    ----------------
    Microsoft Powershell MVP
    https://mvp.support.microsoft.com/profile/Brandon
    Blog: http://www.bsonposh.com
    Brandon Shell [MVP]User is Offline
    Basic Member
    Basic Member
    Posts:396
    Avatar

    --
    25 Mar 2008 11:51 AM
    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/threa...0?tstart=0
    Brandon Shell
    ----------------
    Microsoft Powershell MVP
    https://mvp.support.microsoft.com/profile/Brandon
    Blog: http://www.bsonposh.com
    immad70User is Offline
    New Member
    New Member
    Posts:5
    Avatar

    --
    26 Mar 2008 07:58 AM

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

     

    Thanks,
    Andrew

    halr9000User is Offline
    PowerShell MVP, Site Admin
    Advanced Member
    Advanced Member
    Posts:565
    Avatar

    --
    26 Mar 2008 08:41 AM

    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. ;)

    Community Director, PowerShellCommunity.org
    Co-host, PowerScripting Podcast
    Author, TechProsaic
    Brandon Shell [MVP]User is Offline
    Basic Member
    Basic Member
    Posts:396
    Avatar

    --
    26 Mar 2008 09:27 AM
    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
    Brandon Shell
    ----------------
    Microsoft Powershell MVP
    https://mvp.support.microsoft.com/profile/Brandon
    Blog: http://www.bsonposh.com
    halr9000User is Offline
    PowerShell MVP, Site Admin
    Advanced Member
    Advanced Member
    Posts:565
    Avatar

    --
    26 Mar 2008 10:07 AM
    No clue what you are talking about. :)
    Community Director, PowerShellCommunity.org
    Co-host, PowerScripting Podcast
    Author, TechProsaic
    Brandon Shell [MVP]User is Offline
    Basic Member
    Basic Member
    Posts:396
    Avatar

    --
    26 Mar 2008 01:54 PM
    That explains alot :P
    Brandon Shell
    ----------------
    Microsoft Powershell MVP
    https://mvp.support.microsoft.com/profile/Brandon
    Blog: http://www.bsonposh.com
    You are not authorized to post a reply.


    Active Forums 4.3
    right
    footer   footer
    footer Sponsored by Quest Software • SAPIEN Technologies • Compellent • Microsoft Windows Server 2008 R2 footer
    footer   footer