Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Powershell script from docker file using google/cloud-sdk

I am trying to use powershell script under cloud run.

I have created docker file as below-

FROM google/cloud-sdk
SHELL ["powershell", "-Command"]
COPY file.ps1  /usr/src/
CMD [ "pwsh", "file.ps1"]
 
It is giving me error in  second line-
terminated: Application failed to start: "pwsh" not found (PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/google-cloud-sdk/bin/)
 
it's working fine with .sh (bash) but with powershell it's giving error. Please suggest on this .
 
0 1 623
1 REPLY 1

Hi @gcloudLearning,

Welcome to the Google Cloud Community!

The reason why it is running with .sh (bash) is because bash is automatically installed in the Cloud CLi.  Powershell is not yet installed that's why the application is not starting and "pwsh" is not found.

You should add this after the "FROM google/cloud-sdk" line:

RUN apt-get update && apt-get install -y pwsh

This will install the Powershell on your image. Once you have done this, you should be able to run your Powershell script.

You can also get in touch with Google Cloud Support if the above option doesn't work.

Let me know if it helped, thanks!

Top Solution Authors