Hi all, I have to backup VMX files, I used to use PowerCLI Copy-DatastoreItem and I need similar method (that I cannot find) for a brand new Orchestrator workflow. Can you show me the way? Thanks Fred
Hi,
Take a look at VcFileManager scripting object and its method copyDatastoreFile_Task(...).
thanks a lot llian!
I'm trying to get whole thing working but I'm facing issues. Here the portion of code I wrote:
var myVcServiceContent = new VcServiceContent();
var myVcFileManager = myVcServiceContent.fileManager;
myVcTask_ref = myVcFileManager.copyDatastoreFile_Task(sourceName=myVMXfile, destinationName=destination, force=0);
but myVcFileManager is considered as 'null'. What am I doing wrong?
Thanks a lot
There are several errors in this code.
1) vCenter's managed object cannot be instantiated as Javascript objects using new. Instead, you should get them in some other way.
For example, you can get fileManager as a property from a VcSdkConnection instance. VcSdkConnection type represents a connection to a vCenter server instance configured in vRO. You can get SDK connection either as an input parameter of your workflow (so the user can choose from existing connections), or by getting the list with all connections VcPlugin.allSdkConnections and then selecting one of them by some criteria. Here is a code that picks the fileManager for the first SDK connection:
var fileManager = VcPlugin.allSdkConnections[0].fileManager;
2) The syntax of passing parameter to copyDatasoreFile_Task() call does not seem correct. Instead of parametername=value you should pass only the values.
Thanks a lot llian for helping.
I was thinking about that method and realized it is not exactly what I need. What I do need to do is to copy .vmx files locally and I am struggling to find a way to achieve.
OK, to download vmx file locally, I think you can utilize ovftool command-line utility.
thanks llian
I am thinking also to copy .VMX files from datastore/VMfolder to an NFS datastore.
Could you (or someone else) provide with a code sample to better understand how to use method 'CopyDatastoreFile_Task' ? It would be much appreciated.