Automating Oracle Database and Grid Patch Downloads from Windows 

Disclaimer: The code and information provided in this blog post are for educational purposes only. Use them at your own risk. I am not responsible for any damage, loss, or issues caused by the use of this code or advice.


Introduction

This post explains how to use Windows PowerShell commands to automate the download of Oracle Database and Grid patches for any supported platform, if you’re from a Unix background, PowerShell is the equivalent of your Bash shell but for Windows.

With a single CLI command, you can download patches for both database and grid, specify exact versions (At the time of writing only 19c is supported and versions 19.24 or higher), and target any platform—all fully automated and command-line driven.

The commands uses autoupgrade.jar under the covers which need access to JDK, so I’ve used Adoptium OpenJDK which is downloaded in setup steps automatically.

Examples

For all examples make sure One Off Setup has been completed, this is documented after the usage examples.

  • Start PowerShell as Administrator
    • Type PowerShell in search box on windows
    • Right click “Windows PowerShell” and “Run as Administrator”

Example 1: Download 19.27 RU patches for database and grid on Linux X64:

Invoke-OraPatchDownload -patchVersion 19.27 -Platform LINUX.X64 -grid

Example 2: Download latest recommended database patches only for Windows

Example 3: Download single patch on Windows for 19.28 JDK which is 37860476

Example 4: Download 19.27 RU patches for database and 19.28 grid on Linux X64

  • should work once latest autoupgrade available for general download on 6th Aug 2025

Example 5: Download latest version of Autoupgrade.jar

  • The latest autoupgrade for public download can lag behind MOS version by a few days

Example 6: Download latest Adoptium OpenJDK


One Off Setup

  • You will need an “My Oracle Support” logon that permits patch downloads
  • Start PowerShell as Administrator
    • Type PowerShell in search box on windows
    • Right click “Windows PowerShell” and “Run as Administrator”

Setup Part 1 : Install and Import OraclePatchingAutoupgrade PowerShell module

  • Have observed this command taking a while to respond, be patient
  • You may get prompted to Install NuGet, accept this
  • If Install-Module command is missing you can install or update PowerShellGet to permit this, followed by a PowerShell session restart, using 2 commands below, then retry.

Setup Part 2 : Directory Setup and Software Downloads (OpenJDK and Autoupgrade)

  • Start PowerShell as Administrator
    • Type PowerShell in search box on windows
    • right click PowerShell result and “Run as Administrator”
  • Creates Directory Framework
  • Downloads Adoptium OpenJDK
  • Downloads Oracle Autoupgrade.jar
  • Allow time for software downloads and setup

New-OraPatchSoftwareAndDirectories [-AutoUpgradeBase, default c:\oracle]

  • If the OpenJDK download is corrupted you will see errors, rerun command to download OpenJDK again, this command is rerunnable
    • Note recently I’ve had this download fail and had to rerun several times
    • Steps for a manual download of OpenJDK are included when run, so user can retry manually to download OpenJDK if needed

Review of Directory framework for patching

Setup Part 3: Create Oracle Keystore wallet to hold MOS credentials

  • Start PowerShell as Administrator
    • Type PowerShell in search box on windows
    • right click PowerShell result and “Run as Administrator”
  • Create the Oracle Autoupgrade Keystore
  • You will need to provide a password to secure the keystore
    • This password is not used again as wallet will be created to use SSO
    • If wallet is not created as SSO, then the wallet password is needed each time for a download, but wallet can be shared
  • Now we are in an interactive mode for Autoupgrade
  • Manually add your My Oracle Support Account Username and Password
add -user <MOS email address>
  • Confirm credentials are valid using below command
    • If wrong repeat step to add -user <MOS email address>
    • “list” command will confirm credentials entered are working
      • repeat add -user command if it does not work
  • Save Configuration using exit and answer YES to convert to auto-login