I'm attempting to get the datastore of a VM, but format it in such a way as to be used with vmrun. My current vmrun statement is:
vmrun -T vc -h https://<ipaddress>:443/sdk -u <username> -p <password> runProgramInGuest "[<datastorename>] <datastorefolder>/<virtualmachinename>.vmx" c:\myscript.bat
So the idea is to replace <datastorename> with the name of the LUN that a given virtual machine is running on. In this case, I am running my vmrun statement from inside a PowerCLI script. So I could use a powerCLI variables, if the vmrun statement can take them, and use whatever escape sequences are required to fit the format that vmrun needs for this argument.
That is correct.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Afaik, you can use the "[datastore] folder/name.vmx" notation in the vmrun command.
You can that path quite easily as follows
get-vm | select Name,@{N="VMX path";E={$_.Extensiondata.Config.Files.VmPathName}}
This requires you to run PowerCLI 4.1 !
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi,
Why don't use Invoke-VMScript? It allows you to start process inside the guest, it does the same you want to do with vmrun.exe! Give it a try!
Vitali
PowerCLI Team
Ok thanks. Does Invoke-VMscript require me to know the ESX host of the VM before I write the script so that I can specify the ESX host as a parameter, or can I just log into the vCenter Server? In DRS clusters you don't always know what ESX host a VM is running on unless you use PowerCLI to discover what host it is currently on - just logging into vCenter Server is easier if possible...
You need to provide credentials (-Hostuser & -Hostpassword or -Hostcredential) for the host your guest is running on.
So yes, you will need to know which ESX.
Unless, your ESX account are synchronised between all nodes in the cluster.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
OK, so assuming I have the same credentials already established on every ESX host - i.e., the same username and password, then I really don't need to know which particular host in the cluster my VM happens to be running on - I just add those credentials as arguments?
Thx
That is correct.
____________
Blog: LucD notes
Twitter: lucd22
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference