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

Create LoginAccount with PowerShell

I'm trying to write a powershell script that create a LoginAccount for a windows user.
That script will run directly on the server using the current user credential, which is a Vault Administrator.

Somehow, the call to AddLoginAccount never ends. Using the "same" code in a c# apps works fine.
I'm wondering what is the problem here.

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

# Connect to M-Files Server
Write-Host "Connecting to Server 'localhost' ..."
$server = new-object MFilesAPI.MFilesServerApplicationClass
$serverConnection = $server.Connect()


# Read user info
Write-Host "Read user info"
$userInfo = $server.LoginAccountOperations.GetPersonalInformationFromDomain("MYDOMAIN\MYUSER")

$loginAccount = new-object MFilesAPI.LoginAccountClass
$loginAccount.Set([MFilesAPI.MFLoginAccountType]::MFLoginAccountTypeWindows, "MYDOMAIN", "MYUSER", [MFilesAPI.MFLoginServerRole]::MFLoginServerRoleLogIn, $userInfo.FullName, $userInfo.Email, [MFilesAPI.MFLicenseType]::MFLicenseTypeNamedUserLicense)

Write-Host "Create Login"
$server.LoginAccountOperations.AddLoginAccount( $loginAccount )

Parents
  • Hi Sebastien,

    We've been unable to reproduce the behavior with your script, it seems to work as expected in our environment.  This may be related to permissions.  You mention the user is a Vault Admin, however, this action would require Server Administrator permissions.  If this permission level isn't applied to the user then this would likely be why it's not working in your environment.

    Tom

  • I have tried the script on 3 differents servers (21.2) and 2 differents account (local admin and M-Files SysAdmin).
    Still the script is stuck at creating the login.
    After letting it runs for some hours it runs into an outofmemory (which make no sense).

Reply Children