This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Check-in document via powershell

Hello

I have a business requirement to be able to submit / check-in a new document into a M-Files vault via PowerShell. Pretty simple task (single doc, few properties to set).

What is my best approach ?

Any pointer / advice most appreciated.

Parents
  • Your best strategy would be to use the REST API from PowerShell if you want to do everything in PowerShell script: logging on to a vault,  creating an object, settings properties and uploading a file.

    I have been trying to use the M-Files COM API from PowerShell (Windows PowerShell 5.1), and API calls. Logging in into a vault and using methods like $vault.ObjectFileOperations.FindFilesByChecksumWithNumericalDigests(...) can be easily done in PowerShell script, but setting up some COM objects that need to be used in other API methods is a PITA and I haven't found any way to do it in PowerShell (for example setting up search conditions). PowerShell will throw an error like  "Cannot convert the "System.__ComObject" ... to "Object" which has to do how PowerShell lazy binds COM objects.

    Should you really need to use the M-Files COM API, then program the functionality in a c# .NET full framework 4.x DLL and call this from PowerShell. You can easily add DLLs into the PowerShell runtime with Add-Type cmdlet and use the DLL classes from PowerShell.

Reply
  • Your best strategy would be to use the REST API from PowerShell if you want to do everything in PowerShell script: logging on to a vault,  creating an object, settings properties and uploading a file.

    I have been trying to use the M-Files COM API from PowerShell (Windows PowerShell 5.1), and API calls. Logging in into a vault and using methods like $vault.ObjectFileOperations.FindFilesByChecksumWithNumericalDigests(...) can be easily done in PowerShell script, but setting up some COM objects that need to be used in other API methods is a PITA and I haven't found any way to do it in PowerShell (for example setting up search conditions). PowerShell will throw an error like  "Cannot convert the "System.__ComObject" ... to "Object" which has to do how PowerShell lazy binds COM objects.

    Should you really need to use the M-Files COM API, then program the functionality in a c# .NET full framework 4.x DLL and call this from PowerShell. You can easily add DLLs into the PowerShell runtime with Add-Type cmdlet and use the DLL classes from PowerShell.

Children