How can I run `powershell` command on mcr.microsoft.com/powershell container

My docker image is from mcr.microsoft.com/powershell:latest which has powershell installed. Why do I get this error when build docker image: /bin/sh: 1: Install-Module: not found

Below is my dockerfile:

FROM mcr.microsoft.com/powershell:latest
RUN Install-Module dbatools -Force

I can run the command Install-Module dbatools -Force when I manually launch a container from mcr.microsoft.com/powershell:latest. Why can’t I run it from building the image? Does it have a different context? If it uses my localhost context, does it mean I need to install powershell on my Mac OS?

If I want to run a powershell script as ENTRYPOINT, how can I specify it?

Source: StackOverflow