Installation

Prerequisities

For safety purposes the default execution policy on Windows prevents running any PowerShell scripts. You can see the current policy by running the command:

Get-ExecutionPolicy -List

Scope           ExecutionPolicy
-----           ---------------
MachinePolicy   Undefined
UserPolicy      Undefined
Process         Undefined
CurrentUser     Restricted
LocalMachine    RemoteSigned

To be able to run any local scripts, it should be at least on the RemoteSigned level. You can enable it for current users by executing:

Set-ExecutionPolicy  -Scope CurrentUser RemoteSigned

See the MS PowerShell execution policy docs for more info. Also check the `Unblock-File <https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/unblock-file?view=powershell-7.4> ` functionalkity for files downloaded from internet.

Moravia Nuget repository

The MT Companion PowerShell module is available in Moravia Nuget packages server. To be able to download it from the Moravia Nuget repository, register it first:

$uri = 'https://nuget.moravia.com'
$nuget_repo = @{
    Name = 'Moravia'
    SourceLocation = "$uri/nuget"
    PublishLocation = "$uri/api/v2/package"
    ScriptSourceLocation = "$uri/nuget"
    ScriptPublishLocation = "$uri/api/v2/package"
    InstallationPolicy = 'Trusted'
}
Register-PSRepository @nuget_repo

To verify that the registration was successful, obtain the list of registered repositories. Our previously registered repo should be listed in the output:

Get-PSrepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2
Moravia                   Trusted              https://nuget.moravia.com/nuget/

To verify the module is available under repo run following:

Find-Module -Repo Moravia -Name MTCompanion

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
4.0        MtCompanion                         Moravia        MT Companion functionality

Warning

Note - for users outside of Moravia, the server is not accessible. As a workaround, ask MTCompanion Team for nuget package, then create local repository and place the nuget there.

To create a local repository (for example at c:my-local-Repo), use following command:

$local_nuget_repo = @{
    Name = 'My-Local-Repo'
    SourceLocation = "c:\my-local-repo"
    PublishLocation = "c:\my-local-repo"
    InstallationPolicy = 'Trusted'
}

Register-PSRepository @local_nuget_repo

Then place the nuget there and verify it is available.

Find-Module -Repo My-Local-Repo -Name MTCompanion

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
4.0        MtCompanion                         My-Local-Repo        MT Companion functionality

Module Installation

Now, list the module available in our repository:

Find-Module -Repository Moravia -Name MTCompanion

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
4.0        MtCompanion                         Moravia              MT Companion functionality

To install module, use Install-Module MTCompanion -Repo Moravia -Scope CurrentUser command.

Once the installation is finished, show the installed module info:

Get-InstalledModule  -Name MTCompanion

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
4.0        MtCompanion                         Moravia              MT Companion functionality

And to see all available commands:

Get-Command -Module MTCompanion

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Function        Get-AccessToken                                    4.0        MTCompanion
Function        Get-ClientProfile                                  4.0        MTCompanion
Function        Get-ServerURL                                      4.0        MTCompanion
Function        Invoke-Evaluation                                  4.0        MTCompanion
Function        Invoke-Translation                                 4.0        MTCompanion
Function        Remove-ClientProfile                               4.0        MTCompanion
Function        Save-Translation                                   4.0        MTCompanion
Function        Set-ClientProfile                                  4.0        MTCompanion
Function        Start-Translation                                  4.0        MTCompanion

To get information about any command, use Get-Help CommandName, for example:

Get-Help Get-ClientProfile

NAME
    Get-ClientProfile

SYNOPSIS


SYNTAX
    Get-ClientProfile [<CommonParameters>]


DESCRIPTION
    Get Client profile for LTGEAR.


RELATED LINKS

REMARKS
    To see the examples, type: "get-help Get-ClientProfile -examples".
    For more information, type: "get-help Get-ClientProfile -detailed".
    For technical information, type: "get-help Get-ClientProfile -full".

Authentication - Setup the Client Profile

The scripts authentication requires the valid Client credentials. This information is provided by MT Companion/Logan team (the solution named MoraviaLogin).

Thus, before running any scripts, the Client profile must be set. To do so, execute:

Set-ClientProfile -ClientName "client id" -Label "client label"

You will be prompted to enter the Client secret as well.

To see which client profile is active , run Get-ClientProfile.

Reference

  1. PowerShellGet - modules/scripts management https://docs.microsoft.com/en-us/powershell/module/powershellget/?view=powershell-7