Is it possible to run an entire, large, powershell script in a java application without calling it externally by launching a powershell process with the -file parameter? (passing it via the encodedcommand parameter won't work either because of the commandline lenght limitation).
I.e. is there a java library that enables you to paste your powershellscript inside your java app and run it?
I currently embed the powershellscript inside the java application and write it to disk, but I'm looking for a fileless approach.
powershell -Command {echo yo; $a=get-date; $a|gm; $a.date}works as expected. Keep in mind that there is a maximum command line length (1024 I think it is). You could pass additional powershell code via environment variables, which you're script could dynamically executeiex $env:pscode. Just noticed you said "large". Another approach would be to execute a small bit of PS code via command line, then pipe the bulk of the code from Java to PS. Again you'd dynamically execute the piped code.