Book Image

PowerCLI Cookbook

By : Philip Brandon Sellers
Book Image

PowerCLI Cookbook

By: Philip Brandon Sellers

Overview of this book

Table of Contents (19 chapters)
PowerCLI Cookbook
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Executing native commands inside the guest operating system from PowerCLI


One of the most interesting cmdlets in PowerCLI is the Invoke-VMScript cmdlet. It allows you to execute scripts and commands inside the guest operating system if it is running VMware Tools. There are a lot of exceptions and requirements that need to be met in order for this cmdlet to work. First, forget about commands that require elevated privileges in Windows. If it prompts you with UAC, then it will most likely not work.

There are some prerequisites needed for Invoke-VMScript to work. First, you need to be running a 32-bit PowerCLI window, the VM guest must be running, and it needs to be running VMware Tools. You should be able to connect to port 902 on the ESXi host from the machine running PowerCLI.

Even with several requirements, this capability is handy. Some of the examples that are available on the Internet show starting and stopping application instances using Invoke-VMScript or setting the guest configuration...