Java Azure Function running powershell script

Arnone, Anthony 61 Reputation points
2021-07-26T21:23:04.447+00:00

I have an Azure function using java, as part of the java call I need to run a powershell script, I have done this in the past on windows machined via:

command = "c:\windows\system32\WindowsPowerShell\v1.0\powershell.exe"+" script.ps1 ";
Process powerShellProcess = Runtime.getRuntime().exec(command);

This does not seem to be working, I then tried simply powershell.exe but also no luck, does anyone know how I can run this powershell script via the azure function?

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. MughundhanRaveendran-MSFT 12,506 Reputation points
    2021-10-01T12:04:34.193+00:00

    @Arnone, Anthony ,

    Powershell.exe would always be running in the Azure Function Windows platform. You can confirm this by navigating to the Kudu (Advanced Tools) site , select debug console -> Powershell and run the below command in the powershell console. It will give the path of the powershell.exe in Azure function

    "Get-Process | Select-Object Path"

    136908-capture.png

    136909-image.png

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community looking for help on similar topics.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.