Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Executing PowerShell code at the API level
#1
Background:
Compared to BAT and VBS, PowerShell code is simpler and more understandable, making it very beginner-friendly for programming. Additionally, all Microsoft products have PowerShell interfaces, and there are many powerful open-source libraries available.(https://www.powershellgallery.com/)
Many times, I've encountered various issues when trying to convert PowerShell code to C# using ChatGPT. This conversion often doesn't provide significant value.
 
I have been using the method described in the link below to execute PowerShell code, but it's too slow.
https://www.libreautomate.com/cookbook/P...ython.html
 
I found a method in the link below for executing PowerShell code at the API level.
https://github.com/p3nt4/PowerShdll
 
Is it possible to create a similar class in LA?
 
It would be great if seamless switching and using variables were possible.
For example, the variable name "var1" in C# and "$var1" in PowerShell represent the same variable, with smooth input and output.
I believe this is achievable, perhaps requiring more programming skills.

C# + PowerShell is simply unbeatable. Tongue

E.g:

string var1="""
hello
world
""";

string var2="test.txt";
    
var R = ps.run("""
($var1 -split '\r?\n') -join '|' > $HOME\Desktop\$var2
'hello world'
""");

print.it($"Res: {R}");


Messages In This Thread
Executing PowerShell code at the API level - by Davider - 03-17-2024, 11:31 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)