I'm creating a Context Menu script to allow deletion of languages on my content tree. When the user elects to run this script, I want to prompt them for their password as a confirmation mechanism, similar to the "elevate" mechanic. Is this possible, and how would it be achieved? These users are not administrators, just general content authors.
Here's the gist of my script:
$location = get-location
$languages = Get-ChildItem "master:\sitecore\system\Languages"
$currentLanguage = [Sitecore.Context]::Language.Name
$langOptions = @{};
foreach ($lang in $languages) {
$langOptions[$lang.Name] = $lang.Name
}
$result = Read-Variable -Parameters `
@{ Name = "language"; Value=$currentLanguage; Title="Language to Remove"; Options=$langOptions; },
@{ Name = "includeSubitems"; Value=$false; Title="Include Subitems"; Columns = 4;} `
-Description "Select the language to remove" `
-Title "Remove Language" -Width 650 -Height 360 -OkButtonName "Proceed" -CancelButtonName "Cancel" -ShowHints
if($result -ne "ok") {
Exit
}
$items = @()
$items += Get-Item $location
# add optional subitems
if ($includeSubitems) {
$items += Get-ChildItem $location -Recurse
}
$proceed = Show-Confirm -Title "Are you sure?"
# Prompt user here for their password to verify execution
if ($proceed -ne 'yes') {
Write-Host "Canceling"
Exit
}
$items | Remove-ItemLanguage -Language $language