================================================================================
              README scheduling-powershell-with-taskscheduler.txt
================================================================================

--------------------------------------------------------------------------------
Table of Contents
--------------------------------------------------------------------------------

    [*] Synopsis
    [*] Prerequisites
    [*] Step-by-Step Instructions
    [*] Security Considerations
    [*] Example Script Execution Command

--------------------------------------------------------------------------------
Synopsis
--------------------------------------------------------------------------------

Explain how to run PowerShell scripts on a schedule using Task Scheduler on
Windows.

--------------------------------------------------------------------------------
Prerequisites
--------------------------------------------------------------------------------

1.  Windows Server (any version with Task Scheduler)

2.  PowerShell Desktop 5.1 (powershell.exe) or PowerShell Core 7+ (pwsh.exe)
    installed and available in your PATH.

--------------------------------------------------------------------------------
Step-by-Step Instructions
--------------------------------------------------------------------------------

1.  Open Task Scheduler
    
    Press Windows + R, type taskschd.msc, and press Enter
  
2.  Create a New Task
    
    Click Create Task in the right-hand panel (not "Create Basic Task")

3.  Configure the Task

    General Tab

      - Name: e.g., "Oracle Data Pump Backup"
      - Security Options:
          
          Select: Run whether user is logged on or not

      - Check: Run with highest privileges

    Triggers Tab

      - Click New
      - Choose how often to run the script (e.g., Daily at 2:00 AM)
      - Click OK

    Actions Tab

      - Click New
      - Action: Start a program
      - Program/script:

        pwsh

      - Add arguments (all on one line):

        -NoProfile
        -ExecutionPolicy Bypass
        -File "C:\opt\oracle-dba-toolkit\winbin\Dpump-Backup.ps1"
        -Database SOEDB
        -Username system
        -Password MySecret
        -DumpDir DPUMP_DUMP_DIR
        -LogDir DPUMP_LOG_DIR
        -Retention 30
        -LogFile "C:\Logs\Dpump.log"
        -NoPrompt

    Conditions Tab
	
      - Optional: Uncheck Start the task only if the computer is on AC power

    Settings Tab
      
      - Optional: Enable Allow task to be run on demand
      - Check Stop the task if it runs longer than: and choose an appropriate
        timeout

--------------------------------------------------------------------------------
Security Considerations
--------------------------------------------------------------------------------

1.  Avoid plaintext passwords in scheduled tasks if possible.

2.  Use Windows Credential Manager or secure encrypted credential files for
    production.

3.  If using sensitive credentials, limit access to the script and log files
    using NTFS permissions.

--------------------------------------------------------------------------------
Example Script Execution Command
--------------------------------------------------------------------------------

The commands in this section must be run from a PowerShell session - PowerShell
Desktop 5.1 (powershell.exe) or PowerShell Core 7+ (pwsh.exe).

Oracle Data Pump Backup (pdb1)

    pwsh -NoProfile `
         -ExecutionPolicy Bypass `
         -File "C:\opt\oracle-dba-toolkit\winbin\Dpump-Backup.ps1" `
         -Database "PDB1" `
         -Username "pdbadmin" `
         -Password "MySecret123" `
         -DumpDir "DPUMP_DUMP_DIR" `
         -LogDir "DPUMP_LOG_DIR" `
         -Retention 7 `
         -NoPrompt

Oracle RMAN Backup (cdb1)

    pwsh -NoProfile `
         -ExecutionPolicy Bypass `
         -File "C:\opt\oracle-dba-toolkit\winbin\Rman-Backup.ps1" `
         -Database "CDB1" `
         -Username "sys" `
         -Password "MySecret123" `
         -Type "FULL" `
         -NoPrompt
