Docker容器的PowerShell脚本
我正在尝试从Docker容器运行一个简单的PowerShell脚本。该脚本应该创建一个广告组。 我面临的问题是ActiveIveriveRectory模块不可用,这就是为什么未识别诸如“新组”之类的命令的原因。
这是我的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"]
,这是我的脚本“ rabbitmq-adgroups.ps1”,
Register-PSRepository -Default
Get-PSRepository
Install-Module ActiveDirectory
....
New-ADGroup -Name $SecurityGroup
....
这些是我
- 在构建docker映像时收到的日志消息,它运行的时刻是“运行pwsh -c” get-psrepository命令
警告:无法 找到模块存储库
- 在执行PowerShell脚本时
,命令“ get-psrepository”,“安装模块...”和“ new-Adgroup ...”分别警告:无法找到模块
存储库:没有匹配 ,请尝试查看所有可用的注册模块存储库。
。为指定的搜索条件和模块名称“ Activedirectory ” 检查名称的拼写,或者如果包括路径 再次。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我发现不可能运行一个需要从基于Linux的Docker映像的Active Directory模块的PowerShell脚本,这是我正在做的。...最后,我决定简单地从Windows机器运行脚本没有任何Docker图像。
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....