How can I find which language the editor is currently working in when running a script from the context menu?

Get-Item .

Returns the item, but in the context language that the script session is in.

  • you can use the -Language parameter in the Get-Item call. Get-Item -Path "master:/sitecore/content/xxx" -Language "en"
    – adarsh
    Dec 15, 2017 at 13:31
  • I need to know what language the item is in as the editor is working on it, not get it in a specific language. Dec 15, 2017 at 14:19
  • 1
    How about this? $SitecoreContextItem.Language.Name # Returns the language name Dec 15, 2017 at 14:33
  • Thanks @MichaelWest - does exactly what I needed. Please add as an answer so I can accept. Dec 15, 2017 at 14:38

2 Answers 2


There are several variables found in the book which should make your life easier authoring scripts.

The following variable will give you the language for the script item.

$SitecoreContextItem.Language.Name # Returns the language name
  • Ah, hidden away in the "Interfaces" chapter - I missed that! Dec 15, 2017 at 14:44

You can see by the dropdown "Current Language" under Home - UI Context in Powershell ISE: enter image description here

You can also change if you have multiple languages on your instance

  • I need to get that value in a Sitecore Powershell script that the editor runs from a context menu. They aren't working in the ISE Dec 15, 2017 at 13:15
  • In the case I showed you can directly get the context language using the Sitecore API. For example: $language = [Sitecore.Context]::Language the $language variable will store the context language which is english in this case
    – Diego
    Dec 15, 2017 at 13:33
  • Yes, but this is the context language of the script session, not the editor's item view - right? Dec 15, 2017 at 14:18
  • yes that's right.
    – Diego
    Dec 15, 2017 at 14:21
  • Which, unfortunately, isn't what I need. An editor is going to right click on an item and choose a script from the context menu. In that script I want to know which language the item is currently being viewed in. Dec 15, 2017 at 14:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.