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.