1

I am trying to run a simple powershell script from a docker container. The script is supposed to create an AD group. The problem I am facing is that the ActiveDirectory module is not available, which is why commands such as "New-ADGroup" are not recognized.

This is my DockerFile

FROM packages.company.ch/icbuild/powershell
WORKDIR /app
COPY ./rabbitmq-adgroups-deploy/1.0/ /app
RUN pwsh -c "Get-PSRepository"
CMD [ "pwsh", "rabbitmq-adgroups.ps1"]

And this is my script "rabbitmq-adgroups.ps1"

  Register-PSRepository -Default
  Get-PSRepository
  Install-Module ActiveDirectory
  ....
  New-ADGroup -Name $SecurityGroup
  ....

And these are the log messages I get

  • When building the docker image, the moment it runs the "RUN pwsh -c "Get-PSRepository" command

WARNING: Unable to find module repositories.

  • When executing the powershell script, commands "Get-PSRepository", "Install-Module ..." and "New-ADGroup ..." respectively

WARNING: Unable to find module repositories.

Install-Package: No match was found for the specified search criteria and module name 'ActiveDirectory'. Try Get-PSRepository to see all available registered module repositories.

The term 'Add-ADGroupMember' is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

1

1 Answer 1

0

I found out that it is not possible to run a powershell script that requires the Active Directory module from a Linux based Docker image, which is what I was doing.... At the end I decided to simply run the script from a Windows Machine without any Docker image whatsoever....

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.