M-Files PowerShell Admin Module ?

I’m using M-Files Server version 24.9 and I’m wondering if there is a script-based method (PowerShell script, etc.) to stop a specific vault — or set it to offline — and then bring it online again with another command.

The reason I need this is to safely back up the vault folder. I’ve heard there is something called the M-Files PowerShell Admin Module that might support this.

Is this available, or is there another recommended way to achieve the same result?

Thanks in advance!

Parents Reply Children
  • I have found the solution; the example is a PowerShell script for setting a vault to offline mode.

    # Configuration
    $vaultGuid = "{vault ID}"

    # User credentials – Windows user!
    $authType = 2 # MFAuthTypeSpecificWindowsUser
    $userName = "useraccount" # or another Windows account
    $password = "password" # replace with the actual password
    $domain = "." # dot = local machine

    # TCP/IP connection
    $protocolSequence = "ncacn_ip_tcp"
    $networkAddress = "mfiles server IP"
    $endpoint = 2266
    $encryptedConnection = $false
    $spn = ""
    $localComputerName = ""

    # Load M-Files COM API
    $null = [System.Reflection.Assembly]::LoadWithPartialName("Interop.MFilesAPI")

    # Create connection
    $tzi = New-Object -ComObject MFilesAPI.TimeZoneInformation
    $tzi.LoadWithCurrentTimeZone()

    $server = New-Object -ComObject MFilesAPI.MFilesServerApplication

    # Connect as server administrator
    $server.ConnectAdministrativeEx(
    $tzi,
    $authType,
    $userName,
    $password,
    $domain,
    $spn,
    $protocolSequence,
    $networkAddress,
    $endpoint,
    $encryptedConnection,
    $localComputerName
    )

    # Take the vault offline
    Write-Host "Taking the Vault offline..."
    $server.VaultManagementOperations.TakeVaultOffline($vaultGuid, $true)
    Write-Host "Vault is now offline."