Docker容器的PowerShell脚本

发布于 2025-02-09 03:16:22 字数 845 浏览 1 评论 0原文

我正在尝试从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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

小清晰的声音 2025-02-16 03:16:22

我发现不可能运行一个需要从基于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....

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文