SDL PowerShell Toolkit

SDL is pleased to announce the availability of a beta version of the SDL PowerShell Toolkit.

The SDL PowerShell Toolkit is a set of modules using Windows PowerShell scripting technology and the Project Automation and Translation Provider APIs from the SDL Trados Studio Professional SDK. In a nutshell, the modules provide functions and sample code that you can re-use in your PowerShell scripts to automate SDL Trados Studio. They feature an initial set of code for use in typical Studio automation tasks such as creating a project, a translation memory or a package derived from a project. You can use these as a starting point for your own PowerShell-based efforts. It is assumed that the reader is familiar with Windows PowerShell as well as an initial understanding of the SDL Trados Studio SDK, in particular the project automation API.

Over time, we would like to see the development community develop further modules and helpful functions that we can share with each other.

Best regards, Ian

Ian Davies | Senior Product Manager | SDL | Language Technologies Division | +44 7826843819

Paul Filkin | RWS Group

________________________
Design your own training!

You've done the courses and still need to go a little further, or still not clear? 
Tell us what you need in our Community Solutions Hub

PowerShellToolkit.zip
  • Starting today Sdl Studio PowerShell toolkit became open source on github. You can find more details on this article I wrote:

    Or you can directly go to the source code location here: 

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • Hi,
    I have a problem with this SDL PowerShell Toolkit and I need help.

    The situation is this:
    -> I have a computer with Linux operating system "Ubuntu".
    -> In this computer I have a project, which is created using "Ruby On Rails".
    -> I have a second remote computer with Windows operating system. This computer has "SDL Trados Studio 2014" with professional license, SDK and "SDL PowerShell Toolkit" with powershell script which will be executed.
    -> When I run project, automatically connects to remote computer via SSH using Ruby gem "net-ssh".
    -> Then run powershell script and I get this:
    New-Object : Exception calling ".ctor" with "2" argument(s): "License check failed, with exception: Sdl.ProjectAutomation.FileBased.LicensingException: A valid SDL Trados Studio Professional license is required to use the Project Automation API in a standalone application. at Sdl.ProjectAutomation.FileBased.FileBasedProject.CheckLicense()" At C:\Users\ltvanmk\powershell_sdl_trados_studio\powershell_toolkit\modules\ProjectHelper\ProjectHelper.psm1:95 char:22
    -> I checked "SDL Trados Studio 2014" license and everything ok.
  • I've replied on this thread

     

    Romulus Crisan | Translation Productivity Development Manager | SDL | (twitter) @cromica_82 | (blog) http://www.romuluscrisan.com/

  • Rotten thread, I know... but anyway...

    I started playing with the PowerShell Tookit, modified the modules to accept the Studio path (Studio2, Studio3, etc.) as argument, so that I can easily play with different installed Studio versions... Still playing only with the Sample_RoundTrip script, though...

    But I'm struggling with the filetypes known to the API-created project, in particular a MemoQ XLIFF.

    According to the API documentation, method used by PowerShell Toolkit for creation of new project "creates a new project based on the default project template set up in SDL Trados Studio. "

    But... while Studio 2015 recognizes a *.mqxliff file - apparently because it's included by default, no need to Install File Type from OpenExchange - and produces correct analysis stats, Studio 2014 does not and spits out only zeroes... and I don't understand why, since my Studio 2014 default project template DOES include MemoQ XLIFF file type!

    Even if I create a copy of my default project template as "Default" profile - just in case the API uses the "Default" profile instead a default profile - it still does not work.

    Where is the catch?

  • Did you try to:
    - check in Trados options (not in project settings or template) if the correct filetype is installed and active
    - remove all templates except default, create a project with the ideal settings in trados and update the default template that way

    - install "variableexplorer" inside powershell and try, by setting breakpoints, to check the properties of passed objects, sometimes the error lies elsewhere...

    https://gallery.technet.microsoft.com/PowerShell-ISE-VariableExpl-fef9ff01

    Hope this helps while waiting for more expert answers.

    Good luck!
  • Yes, I do have the filetype visible and active in the global Options dialog.

    I will look into the variable explorer, but since all this crazy PowerShell stuff is all Greek to me, I can't gurantee it will help me.

    Again... this entire move away from COM is VERY BAD signal to (power)users.
    Everything used to be SOOOO simple for users without development background... And this .NET-ish stuff is pure signal to these users that nobody cares about this group anymore and that ONLY real developers are in the view :(
  • Well.. systems and applications used to be more simple too.

    I think more and more users will be split among normal users and developers, normal users will have everything "ready to use" without any access to under the hood thinkering, while to mess with stuff you will have to be properly trained.

    the SDL PS SDK is anyway a welcome option for power users, once you get accustomed to PS is not that bad.
  • Well, but that "once you get accustomed to PS" is the problematic condition here.
    Despite many developers' claims, PowerShell is NOT something commonly used and known. It's a fact. Period. Microsoft is ~20 years late here (just as is with the "revolutionary" commandline console enhancements in Windows 10).

    Anyway, after my first few days with PowerShell and the PowerShell toolkit I can only say that it should have been somehow updated before releasing it... several years and several Trados Studio versions after it was created...

    Trying to run the sample on a today's standard Windows 7 machine coming with PS 2.0 led to a huge number of weirdly looking errors which I, as a total PS newbie, was not able to understand.
    It took me several hours of googling, editing some XML config files in order to overcome some PS 2.0 vs. .NET 4.x incompatibilities, a LOT of swearing and countless trials and errors until I finally gave up and installed PS 4.0, which washed away the errors...
    Is THIS really supposed to be easy for users?! Is this really supposed to encourage someone to start playing with the toolkit? Come on, you can't be serious...
    If something is for free, it doesn't mean that it should not work.

    Plus, the PS code in the sample deserves some update too... even I now know that e.g. "Write-Host" should not be used unless really necessary (Write-Output is the right way).
    I understand that the code was probably created before these best practices were published, that's fine (when I look back at some of my early scripts, I would slap myself too), but it was released only now, so should have been reviewed before release...
  • I can't use Powershell Toolkit with Studio 2015...

    I have modified the default modules to accept Studio version to be used in the "Add-Type" path, so that I can easily test the toolkit with 2011, 2014 or 2015 version (installed on the same machine).... and while it works just fine when run with 2014 (the Sample Roundtrip script runs successfully), when run with 2015, all I get is a bunch of errors.

    I'm not a developer (this .NET sh*t is a reall HELL), so I don't have a clue what is that crap telling me...

    SDL EXPERTS - it's your product, so be so kind and tell me what's wrong.
    According to $PSVersionTable I should be running PS 4.0... Win7 x64 with .NET Framework installed in all versions you can think of...

    And - when are you going to update the toolkit to work out-of-the-box with recent Studio version (so that it's actually USEFUL to anyone willing to start with it)?!

  • Hi Evzen,

    I think you only need to modify a couple places.

    In TMHelper.psm1 change the function New-FileBasedTM to the following:

    function New-FileBasedTM
    {
    	param([String] $filePath,[String] $description, [String] $sourceLanguageName, [String] $targetLanguageName, 
    		[Sdl.LanguagePlatform.TranslationMemory.FuzzyIndexes] $fuzzyIndexes, 
    		[Sdl.LanguagePlatform.Core.Tokenization.BuiltinRecognizers] $recognizers,
                    [Sdl.LanguagePlatform.Core.Tokenization.TokenizerFlags] $tokenizers,
                    [Sdl.LanguagePlatform.TranslationMemory.WordCountFlags] $wordCountFlags)
    	
    	
    	$sourceLanguage = Get-CultureInfo $sourceLanguageName;
    	$targetLanguage = Get-CultureInfo $targetLanguageName;
    
    	[Sdl.LanguagePlatform.TranslationMemoryApi.FileBasedTranslationMemory] $tm = 
    	New-Object Sdl.LanguagePlatform.TranslationMemoryApi.FileBasedTranslationMemory ($filePath,
    	$description, $sourceLanguage, $targetLanguage, $fuzzyIndexes, $recognizers, $tokenizers, $wordCountFlags);	
    }

     

    Then in Sample_Roundtrip.ps1, modify line 16 as follows:

    New-FileBasedTM $tmFilePath "Created by PowerShell" "en-US" "de-DE" $indexes $recognizers 7 4;

    # 7 and 4 are the defaults

     

    Long story short, the constructor found below has two more parameters (8 in total) in Trados Studio 2015 (in previous versions there were only 6 parameters). So the code above needs to be modified like the above to work.

    Let me know if that works for you.