Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Scheduled PowerShell Task Not Renaming File

Prerna Lade
Kilo Contributor

Hi everyone,

 

I have a PowerShell script scheduled to run via **Task Scheduler**. Its job is simple:

It renames (or copies) the latest file from the following folder using a standard name:

 

```

C:\Program Files\ServiceNow Midserver Common\Oracle\All Oracle databases end of support\

```

 

The script runs perfectly when I execute it manually, but when triggered by Task Scheduler:
 It fails with this message:

  **“Administrator has refused the request ”**

  “Launch request ignored, instance already running”

 

 

What the script does:

* Gets the latest modified file in the folder

* Copies/renames it with a fixed name (`All Oracle databases end of support - SN.xls`)

 

Task Scheduler Configuration:

 

Trigger: Daily at a fixed time

“Run with highest privileges”: Not enabled

“Run whether user is logged on or not”: Enabled

 

Other PowerShell-based tasks are working fine
 I suspect the issue is related to permissions or folder location

I’d prefer not to enable “Run with highest privileges” unless necessary

 

 

Any insights or best practices would be appreciated. Thanks!

0 REPLIES 0