EPM - Execute Script Policy not working correctly for PowerShell script
Question
When a PowerShell script is executed by either Execute Script Policy or Deploy Script Policy, the script will not be executed successfully if the script includes a section where it accesses Microsoft Excel.
If the script is run manually via PowerShell application in the endpoint, the script will be executed with no errors.
Environment
22.10;22.11;22.12;23.1 EPM Windows Agent
Answer
Please note that this is a bug of the Windows OS.
This bug occurs specifically when running an automated PowerShell script that is accessing Microsoft Excel.
Please refer to this blog for more information:
Automating Excel 2007 on Windows Server 2008 64-bit
The solution for this Windows bug can be changed in other OS versions, but it works and have been tested on Windows 10.
The solution goes as follows:
1. In the endpoint, create the following directories:
C:\Windows\SysWOW64\config\systemprofile\Desktop
C:\Windows\System32\config\systemprofile\DesktopĀ
2. For the created Desktop directories, add Full control permissions for the relevant user.
3. Configure a new Execute Script policy and check if it works by request settings at the affected endpoint.
For Deploy Script policy, execute the script from the Control Panel.