Windows 如何使用docker文件在docker容器内安装powershell模块
我有一个基本的powershell脚本,可以对SharePoint online(Office365)进行更改。此任务要求在要执行脚本的系统中安装Microsoft.Online.SharePoint.PowerShell模块 下面是我的docker文件:Windows 如何使用docker文件在docker容器内安装powershell模块,windows,docker,powershell,containers,Windows,Docker,Powershell,Containers,我有一个基本的powershell脚本,可以对SharePoint online(Office365)进行更改。此任务要求在要执行脚本的系统中安装Microsoft.Online.SharePoint.PowerShell模块 下面是我的docker文件: FROM mcr.microsoft.com/powershell:latest WORKDIR ./ CMD pwsh -Command Install-Module Microsoft.Online.SharePoint.PowerS
FROM mcr.microsoft.com/powershell:latest
WORKDIR ./
CMD pwsh -Command Install-Module Microsoft.Online.SharePoint.PowerShell -Scope CurrentUser -Force
COPY SampleScript.ps1 ./
CMD pwsh .\SampleScript.ps1
当我跑步时:
docker运行——名称为“pwsh演示”——交互式——tty dockerdemo
我无法进入交互模式。但当我试图手动进入容器并在不使用dockerfile的情况下手动安装模块时,模块正在安装,但当我运行脚本时,它抛出错误,表示:
The term 'Connect-SPOService' 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.
虽然模块已安装,但我使用以下命令进行了验证:
获取模块-列表可用