knife-vsphere icon indicating copy to clipboard operation
knife-vsphere copied to clipboard

Does "knife vsphere vm execute VMNAME COMMAND ARGS" work for Windows Guest?

Open yangpeng-chn opened this issue 3 years ago • 0 comments

Hi,

I need to run several commands against my Windows Guest after cloning a VM from the template. I tried to configure "Run Once" in Customization Specification Manager from vSphere but it does not seem to work. Then I noticed I can run command on Guest with knife vsphere vm execute VMNAME COMMAND ARGS but it does not seem to work either. The error is:

knife vsphere vm execute HOSTNAME--exec-user ADMIN--exec-passwd PASSWORD -- C:\\Windows\\System32\\xcopy C:\\Windows\\System32\\drivers\\etc\\hosts C:\\tmp
ERROR: RbVmomi::Fault: FileNotFound: File C:\Windows\System32\xcopy was not found

I also tried the following but with no luck.

knife vsphere vm execute HOSTNAME--exec-user ADMIN--exec-passwd PASSWORD -- /C/Windows/System32/xcopy /C/Windows/System32/drivers/etc/hosts /C/tmp
knife vsphere vm execute HOSTNAME--exec-user ADMIN--exec-passwd PASSWORD -- C:\Windows\System32\xcopy C:\Windows\System32\drivers\etc\hosts C:\tmp

yangpeng-chn avatar Oct 02 '20 05:10 yangpeng-chn