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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With