We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

custom PowerShell scripts still run from service account profile path (Access denied) - Zurich

Atiruveedula
Kilo Explorer

Hi all,

Running custom PowerShell actions on a Windows MID Server (Zurich) and hitting a wall I'm hoping someone has seen.

The situation:
- OOTB spoke PowerShell actions (ADv2, etc.) work fine - their scripts already live on the MID Server and run in place.
- Custom PowerShell actions fail with "Access is denied". The reason appears to be that the custom script is copied into a hidden AppData directory in the MID Server service account's profile, but then executed under a different PowerShell service account that has no access to that profile directory.

Error seen:
- Failed while executing commandScript<...>.PS1 (Access denied)
- PowerShell script execution failed. Script returned status 1

What I tried:
- Set the MID Server property mid.powershell.target_base_dir to a neutral folder (e.g. c:\temp\snow) that both service accounts can access.
- Confirmed the property has taken effect on the MID Server.
- BUT custom scripts are still being written to / executed from the service account profile path, not the folder I configured.

Questions for anyone who's done this:
1. Is mid.powershell.target_base_dir the correct property to relocate where custom PowerShell scripts are written/executed? Or is it a different property/spelling?
2. Has anyone seen it not take effect (scripts still run from the profile AppData path) - known bug / specific patch?
3. What's your SUPPORTED setup for getting custom PowerShell to run from a location both the MID Server service account and the execution account can access, without loosening Windows security?
4. Any working approach to align the execution account and script location for custom actions?

Environment: ServiceNow Zurich, Windows MID Server, PowerShell 5.1, custom actions used by ADv2 / Exchange Online spokes.

1 REPLY 1

Tanushree Maiti
Tera Patron

Hi @Atiruveedula 

 

Refer article/post: 

Powershell Action – Authentication failure with the user administrator

 

https://www.servicenow.com/community/common-service-data-model-forum/error-access-denied-script-retu...

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti