I wanted to give user to execute some operation for selected item on the click of button present in the Sitecore ribbon.
For executing the operation, I used a Powershell command like below:
item:executescript(id=$Target,script={ItemID},scriptDb=master)
However, I encountered difficulty in identifying the context item on which the operation should be executed.
I found the answer after searching for a bit. Context Item and path can be found by any one of the following:
$SitecoreContextItem
Get-Item -Path .
Get-Item -Path "."
Get-Item .
Get-Item "."
(Get-Location).path
($pwd).path
Similarly, you can find more information about such keywords by running:
Get-Variable

I hope this proves helpful for you.
Good Luck!
Leave a comment