There is a limitation called ExecutionPolicy
, setting, which can prevent from running scripts from files.
From C#, you can create an instance of InitialSessionState
with ExecutionPolicy = ByPass
and create Powershell with this initial session state. Then try to run your script file with Invoke-Command -FilePath
command.
solved How to check PowerShell disable by group policy using C#