When trying to use the Utility: Run a script function in a Host Integrity(HI) policy, the Powershell script isn't executed but HI reports success.
-File parameter missing from "Execute the command*" field.
When using a PowerShell script, in the "EXECUTE THE COMMAND*" field, it must be formatted like:
powershell -File %F%
The -File parameter is necessary for PowerShell to get the full file path and file name of the script. %F% is the variable which points to the path + script file name.
Additionally, depending on the PowerShell Execution Policy set on the target system of the HI policy, PowerShell scripts may be blocked from running by the system configuration. For more information about PowerShell Execution policies, visit the Microsoft documentation below.
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies?view=powershell-7.4