I have a C# method that generates powershell scripts.
Is there a way to automatically validate the syntax of the generated scripts directly in C# before running them on the end client?
I have a C# method that generates powershell scripts.
Is there a way to automatically validate the syntax of the generated scripts directly in C# before running them on the end client?
You could possibly use the
Parser.ParseFile method from the PowerShell SDK, which might be found in the Microsoft.PowerShell.SDK nuget
Note : I have never used this and is totally untested, and truthfully i have no idea whether this will work for you.