-
-
Save mavaddat/d450dcd63c9c4edd27124b045a777585 to your computer and use it in GitHub Desktop.
# Get the ID and security principal of the current user account | |
$myWindowsID=[System.Security.Principal.WindowsIdentity]::GetCurrent() | |
$myWindowsPrincipal=new-object System.Security.Principal.WindowsPrincipal($myWindowsID) | |
# Get the security principal for the Administrator role | |
$adminRole=[System.Security.Principal.WindowsBuiltInRole]::Administrator | |
# Check to see if we are currently running "as Administrator" | |
if ($myWindowsPrincipal.IsInRole($adminRole)) | |
{ | |
# We are running "as Administrator" - so change the title and background color to indicate this | |
$Host.UI.RawUI.WindowTitle = $myInvocation.MyCommand.Definition + "(Elevated)" | |
$Host.UI.RawUI.BackgroundColor = "DarkBlue" | |
clear-host | |
} | |
else | |
{ | |
# We are not running "as Administrator" - so relaunch as administrator | |
# Create a new process object that starts PowerShell | |
$newProcess = new-object System.Diagnostics.ProcessStartInfo "PowerShell"; | |
# Specify the current script path and name as a parameter | |
$newProcess.Arguments = $myInvocation.MyCommand.Definition; | |
# Indicate that the process should be elevated | |
$newProcess.Verb = "runas"; | |
# Start the new process | |
[System.Diagnostics.Process]::Start($newProcess); | |
# Exit from the current, unelevated, process | |
# exit | |
} | |
# Running code that needs to be elevated here | |
# A flexible way to determine the Photoshop path is below | |
$registryPath = $('Registry::'+$(Get-ChildItem -Path 'Registry::HKEY_CURRENT_USER\Software\Adobe\Photoshop\' -ErrorAction Inquire | Select-String -Pattern '[\w_\\]+\d+\.\d+')) | |
$name = "OverridePhysicalMemoryMB" | |
# Determine amount of installed RAM system memory in MB from cim_physical memory | |
$value = (Get-WmiObject -class "cim_physicalmemory" | Measure-Object -Property Capacity -Sum).Sum/ 1024 / 1024 | |
IF([string]::IsNullOrEmpty( $(Get-ChildItem -Path 'Registry::HKEY_CURRENT_USER\Software\Adobe\Photoshop\' -ErrorAction SilentlyContinue | Select-String -Pattern '[\w_\\]+\d+\.\d+')) -or !(Test-Path $registryPath)) | |
{ | |
$host.ui.WriteErrorLine("Cannot find Adobe Photoshop installation location in the system registry.`r`nTry installing or re-installing Adobe Photoshop first.") | Out-Null | |
} | |
ELSE | |
{ | |
New-ItemProperty -Path $registryPath -Name $name -Value $value -PropertyType DWORD -Force -Verbose | |
} | |
Write-Host "Please press any key to continue..." | Out-Null | |
$Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyDown")| Out-Null |
I get this error unfortunately:
Exception calling "DownloadString" with "1" argument(s): "The request was aborted: Could not create SSL/TLS secure
channel."
At line:1 char:1
- iex(New-Object Net.WebClient).DownloadString('https://gist.github.com ...
-
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : WebException
Something to do with the wrong TLS maybe?
Script should be flexible to handle older versions as well, not just the latest. The same registry settings applies.
"Photoshop\120.0"
@Glennmartyn I have now updated the instructions to clarify how to prepare your PowerShell terminal for SSL/TLS Invoke-WebRequest. Please notice that I have merely implemented one of the solutions provided in this StackExchange discussion.
I now instruct people to preface the Invoke-Webrequest command with the code
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
This allows PowerShell to communicate along secure HTTPS channels.
@Drout I have now updated the script to be flexible to other versions of Adobe Photoshop. Good suggestion.
@mavaddat: thank you so so much........I had the problem titled "exception access violation" in CC 2018 version while trying to apply a function on a 'duplicate layer' of a photo........after creating this DWORD value now it's accessing about 1000MB in RAM and it's running with no error..........wish you good luck brother 👍
This Powershell script implements the solution described by JDH_2017 to fix Adobe Photoshop CC memory issue #2416657

The workaround involves telling Photoshop how much memory is installed in your system in a DWORD called OverridePhysicalMemoryMB at
\Computer\HKEY_CURRENT_USER\Software\Adobe\Photoshop\120.0
To run this in your PowerShell without modifying your execution policy, try the following one-liner in PowerShell terminal:
Always closely examine the source code for a script before running it on your system to ensure that the script is not executing any malicious commands.
Detailed instructions
X
, then hit "I
"wait a moment for the PS command prompt to appear