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 functionalkity for files downloaded from internet.
Powershell module repository
This howto is based on [PowershellAzureArtifactFeed] - if anything is unclear it should be read first. See
Note
The module former location on Moravia nuget server is no longer available. Use the new service on Azure DevOps.
The Module management in Powershell is managed by [PSResourceGet] module. Thus install first those modules:
Install-Module Microsoft.PowerShell.PSResourceGet -Force
Install-Module Microsoft.PowerShell.SecretManagement
Install-Module Microsoft.PowerShell.SecretStore
The Companion PowerShell module is available on RWS private Azure Artifacts Feed repository. User must have an account there to be able to download the module.
Create Personal Access token
Personal Access token (PAT) is a secure way to autheticate to Azure DevOps.
Login to the DevOps server
Navigate to your Azure DevOps organization https://dev.azure.com/rwsworldwide
Select the user settings icon, select Personal access tokens, and then select New Token.
Enter a name for your PAT, set an Expiration date, select Custom defined, and then select Packaging > Read.
Select Create and save the PAT in safe place.
Then setup your credentials for powershell session.
$patToken = "<PERSONAL_ACCESS_TOKEN>" | ConvertTo-SecureString -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential("<USER_NAME>", $patToken)
Register-SecretVault -Name "MySecretVault" -ModuleName Microsoft.PowerShell.SecretStore -DefaultVault
Set-Secret -Name "MyCredential" -Secret $credentials -Vault "MySecretVault"
$CredentialInfo = [Microsoft.PowerShell.PSResourceGet.UtilClasses.PSCredentialInfo]::new('MySecretVault', 'MyCredential')
Register repository
Register-PSResourceRepository -Name 'RWS AzureDevOps Feed' `
-Uri "https://pkgs.dev.azure.com/rwsworldwide/_packaging/rwsworldwide/nuget/v3/index.json" `
-Trusted `
-CredentialInfo $CredentialInfo
To verify that the registration was successful, obtain the list of registered repositories. Our previously registered repo should be listed in the output:
Get-PSResourceRepository
Name Uri Trusted Priority
---- --- ------- --------
PSGallery https://www.powershellgallery.com/api/v2 False 50
RWS AzureDevOps Feed https://pkgs.dev.azure.com/rwsworldwide/_packaging/rwsworldwide/nuget/v3/index.json True 50
To verify the module is available under repo run following:
Find-PSResource -Repo 'RWS AzureDevOps Feed' -Name MTCompanion
Name Version Prerelease Repository Description
---- ------- ---------- ---------- -----------
MTCompanion 4.3.1 RWS AzureDevOps Feed MT Companion - PowerShell Automation Module
Manuall download
In case user has forbidden acccess to AzureDevOps, module could be provided by explicit request to Companion product owner. Once the package is provided, 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_repoThen place the nuget there and verify it is available.
Find-PSResource -Repo My-Local-Repo -Name MTCompanion Name Version Prerelease Repository Description ---- ------- ---------- ---------- ----------- MTCompanion 4.3.1 My-Local-Repo MT Companion - PowerShell Automation Module
Module Installation
Now, list the module available in our repository:
Find-PSResource -Repo 'RWS AzureDevOps Feed' -Name MTCompanion
Name Version Prerelease Repository Description
---- ------- ---------- ---------- -----------
MTCompanion 4.3.1 RWS AzureDevOps Feed MT Companion - PowerShell Automation Module
To install module, use Install-PSResource MTCompanion -Repo 'RWS AzureDevOps Feed' -Scope CurrentUser command.
Once the installation is finished, show the installed module info:
Get-InstalledPSResource -Name MTCompanion
Name Version Prerelease Repository Description
---- ------- ---------- ---------- -----------
MTCompanion 4.3.1 RWS AzureDevOps Feed MT Companion - PowerShell Automation Module
And to see all available commands:
Get-Command -Module MTCompanion
CommandType Name Version Source
----------- ---- ------- ------
Function Add-HumanEvaluationLanguagePair 4.3.1 MTCompanion
Function Export-HumanEvaluationReport 4.3.1 MTCompanion
Function Export-HumanEvaluationReportFromTsv 4.3.1 MTCompanion
Function Get-AccessToken 4.3.1 MTCompanion
Function Get-ClientProfile 4.3.1 MTCompanion
Function Get-HumanEvaluationJob 4.3.1 MTCompanion
Function Get-HumanEvaluationReportTemplate 4.3.1 MTCompanion
Function Get-ServerURL 4.3.1 MTCompanion
Function Get-Workspace 4.3.1 MTCompanion
Function Invoke-Evaluation 4.3.1 MTCompanion
Function Invoke-Translation 4.3.1 MTCompanion
Function New-HumanEvaluationReport 4.3.1 MTCompanion
Function Remove-ClientProfile 4.3.1 MTCompanion
Function Save-Translation 4.3.1 MTCompanion
Function Set-ClientProfile 4.3.1 MTCompanion
Function Start-Translation 4.3.1 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 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
modules/scripts management https://docs.microsoft.com/en-us/powershell/module/powershellget/?view=powershell-7
Use an Azure Artifacts Feed as private PowerShell repository https://learn.microsoft.com/en-us/azure/devops/artifacts/tutorials/private-powershell-library?view=azure-devops&pivots=psresourceget