-
Notifications
You must be signed in to change notification settings - Fork 0
/
right-klick-AdminPS.ps1
82 lines (80 loc) · 6.85 KB
/
right-klick-AdminPS.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
If (!(Test-Path "HKCR:"))
{
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
}
$registryPath = "HKCR:\Directory\Background\shell"
$Name = "AdminPowershell"
New-Item -Path $registryPath -Name $Name -Force | Out-Null
$registryPath = "HKCR:\Directory\Background\shell\AdminPowershell"
$Name = "command"
New-Item -Path $registryPath -Name $Name -Force | Out-Null
$registryPath = "HKCR:\Directory\Background\shell\AdminPowershell\command"
$Name = "(Default)"
$value = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe start-process powershell -verb runas"
IF(!(Test-Path $registryPath))
{
New-Item -Path $registryPath -Force | Out-Null
}
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force | Out-Null
If (!(Test-Path "HKCR:"))
{
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
}
$registryPath = "HKCR:\Directory\Background\shell"
$Name = "AdminPowershellISE"
New-Item -Path $registryPath -Name $Name -Force | Out-Null
$registryPath = "HKCR:\Directory\Background\shell\AdminPowershellISE"
$Name = "command"
New-Item -Path $registryPath -Name $Name -Force | Out-Null
$registryPath = "HKCR:\Directory\Background\shell\AdminPowershellISE\command"
$Name = "(Default)"
$value = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe start-process powershell_ise -verb runas"
IF(!(Test-Path $registryPath))
{
New-Item -Path $registryPath -Force | Out-Null
}
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force | Out-Null
If (!(Test-Path "HKCR:"))
{
New-PSDrive -Name HKCR -PSProvider Registry -Root HKEY_CLASSES_ROOT | Out-Null
}
$registryPath = "HKCR:\Directory\Background\shell"
$Name = "\OpenPowershellHere"
New-Item -Path $registryPath -Name $Name -Force | Out-Null
$registryPath = "HKCR:\Directory\Background\shell\OpenPowershellHere"
$Name = "command"
New-Item -Path $registryPath -Name $Name -Force | Out-Null
$registryPath = "HKCR:\Directory\Background\shell\\OpenPowershellHere\command"
$Name = "(Default)"
$value = "C:\windows\system32\WindowsPowerShell\v1.0\powershell.exe -noexit -command Set-Location -LiteralPath '%V'"
IF(!(Test-Path $registryPath))
{
New-Item -Path $registryPath -Force | Out-Null
}
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType String -Force | Out-Null
<#
#Here is a version that adds “Open Powershell” with a submenu of “Open Powershell here” and “Open Powershell here Admin”
if((Test-Path "HKLM:\SOFTWARE\Classes\Directory\shell\01MenuPowerShell") -ne $true) { New-Item "HKLM:\SOFTWARE\Classes\Directory\shell\01MenuPowerShell" -force -ea SilentlyContinue };
if((Test-Path "HKLM:\SOFTWARE\Classes\Directory\background\shell\01MenuPowerShell") -ne $true) { New-Item "HKLM:\SOFTWARE\Classes\Directory\background\shell\01MenuPowerShell" -force -ea SilentlyContinue };
if((Test-Path "HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\open") -ne $true) { New-Item "HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\open" -force -ea SilentlyContinue };
if((Test-Path "HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\open\command") -ne $true) { New-Item "HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\open\command" -force -ea SilentlyContinue };
if((Test-Path "HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\runas") -ne $true) { New-Item "HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\runas" -force -ea SilentlyContinue };
if((Test-Path "HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\runas\command") -ne $true) { New-Item "HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\runas\command" -force -ea SilentlyContinue };
if((Test-Path "HKLM:\SOFTWARE\Classes\Directory\shell\Powershell") -ne $true) { New-Item "HKLM:\SOFTWARE\Classes\Directory\shell\Powershell" -force -ea SilentlyContinue };
if((Test-Path "HKLM:\SOFTWARE\Classes\Directory\background\shell\Powershell") -ne $true) { New-Item "HKLM:\SOFTWARE\Classes\Directory\background\shell\Powershell" -force -ea SilentlyContinue };
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\shell\01MenuPowerShell' -Name 'MUIVerb' -Value "Open PowerShell" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\shell\01MenuPowerShell' -Name 'Icon' -Value "powershell.exe" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\shell\01MenuPowerShell' -Name 'ExtendedSubCommandsKey' -Value "Directory\\ContextMenus\\MenuPowerShell" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\background\shell\01MenuPowerShell' -Name 'MUIVerb' -Value "Open PowerShell" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\background\shell\01MenuPowerShell' -Name 'Icon' -Value "powershell.exe" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\background\shell\01MenuPowerShell' -Name 'ExtendedSubCommandsKey' -Value "Directory\\ContextMenus\\MenuPowerShell" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\open' -Name 'MUIVerb' -Value "PowerShell here" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\open' -Name 'Icon' -Value "powershell.exe" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\open\command' -Name '(default)' -Value "powershell.exe -noexit -command Set-Location '%V'" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\runas' -Name 'MUIVerb' -Value "PowerShell here (Admin)" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\runas' -Name 'Icon' -Value "powershell.exe" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\runas' -Name 'HasLUAShield' -Value "" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\ContextMenus\MenuPowerShell\shell\runas\command' -Name '(default)' -Value "powershell.exe -noexit -command Set-Location '%V'" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\shell\Powershell' -Name 'Extended' -Value "" -PropertyType String -Force -ea SilentlyContinue;
New-ItemProperty -Path 'HKLM:\SOFTWARE\Classes\Directory\background\shell\Powershell' -Name 'Extended' -Value "" -PropertyType String -Force -ea SilentlyContinue;
#>