Add 'Open Powershell here as admin' option to folder context menu

I have been looking for a way to open an elevated Powershell prompt from Windows Explorer directly, via the context menu of the folder I want to open the prompt in.
I'm using Windows 10 and all the examples I've seen so far have been for older versions of Windows. I previously had this working on Windows 8.1, but the update to 10 broke it. I even got this working on Windows 10 briefly, but an update broke it again (Dec 2015).

Does anyone know the correct way to add this feature to Windows? Or is it doomed to be overwritten by future updates to Windows?


This is the only way I know of to currently add this feature to context menus in Windows Explorer:

[Run this script in an elevated powershell prompt]

$menu = 'Open Windows PowerShell Here as Administrator'
$command = "$PSHOME\powershell.exe -NoExit -NoProfile -Command ""Set-Location '%V'"""

'directory', 'directory\background', 'drive' | ForEach-Object {
    New-Item -Path "Registry::HKEY_CLASSES_ROOT\$_\shell" -Name runas\command -Force |
    Set-ItemProperty -Name '(default)' -Value $command -PassThru |
    Set-ItemProperty -Path {$_.PSParentPath} -Name '(default)' -Value $menu -PassThru |
    Set-ItemProperty -Name HasLUAShield -Value ''
}

This script taken from the following link:

http://www.powershellmagazine.com/2013/06/25/pstip-how-to-start-an-elevated-powershell-from-windows-explorer/

I'm 99% certain that this was the way I did it before the latest Windows patch 'removed' my registry setting (it also removed some other customisations, like numlock boot status, but that is less annoying).

If anyone knows a better approach; i.e. that won't be volatile, then please let me know and I'll accept that answer.


I've been doing it like this. It is part of a little menu I made. Edit it to your liking:

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\CommandStore\shell\OAPS.Tools]
"ImpliedSelectionModel"=dword:00000001
"Icon"="imageres.dll,-5373"
"ExplorerCommandHandler"="{BF0AC53F-D51C-419F-92E3-2298E125F004}"
@="Admin Pshell Here"