powershell: [BUG] Connect-PNPOnline fails in powershell docker container with "No such file or directory"
Environment
Powershell ubuntu LTS Docker image using VScode remote development
Dockerfile (vscode default-ish)
FROM mcr.microsoft.com/powershell:lts-ubuntu-18.04
# [Option] Install zsh
ARG INSTALL_ZSH="false"
# [Option] Upgrade OS packages to their latest versions
ARG UPGRADE_PACKAGES="true"
# Install needed packages and setup non-root user. Use a separate RUN statement to add your own dependencies.
ARG USERNAME=vscode
ARG USER_UID=1000
ARG USER_GID=$USER_UID
COPY library-scripts/*.sh /tmp/library-scripts/
RUN apt-get update \
&& /bin/bash /tmp/library-scripts/common-debian.sh "${INSTALL_ZSH}" "${USERNAME}" "${USER_UID}" "${USER_GID}" "${UPGRADE_PACKAGES}" "true" "true" \
&& chsh "${USERNAME}" -s "$(which pwsh)" \
&& apt-get autoremove -y && apt-get clean -y && rm -rf /var/lib/apt/lists/* /tmp/library-scripts
SHELL [ "pwsh", "-c" ]
RUN Install-Module -Force -Scope AllUsers -Verbose -Name ExchangeOnlineManagement -RequiredVersion 2.0.5
RUN Install-Module -Force -Scope AllUsers -Verbose -Name PnP.Powershell -RequiredVersion 1.7.0
RUN Install-Module -Force -Scope AllUsers -Verbose -Name ImportExcel -RequiredVersion 7.2.1
# [Optional] Uncomment this section to install additional packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
Log
Url: PS /workspaces/xxx> connect-pnponline -url 'https://xxx.sharepoint.com/sites/xxx' -interactive
Connect-PnPOnline: No such file or directory
PS /workspaces/xxx> get-error
Exception :
Type : System.ComponentModel.Win32Exception
NativeErrorCode : 2
ErrorCode : -2147467259
TargetSite :
Name : ForkAndExecProcess
DeclaringType : System.Diagnostics.Process
MemberType : Method
Module : System.Diagnostics.Process.dll
StackTrace :
at System.Diagnostics.Process.ForkAndExecProcess(String filename, String[] argv, String[] envp, String cwd, Boolean redirectStdin, Boolean
redirectStdout, Boolean redirectStderr, Boolean setCredentials, UInt32 userId, UInt32 groupId, UInt32[] groups, Int32& stdinFd, Int32&
stdoutFd, Int32& stderrFd, Boolean usesTerminal, Boolean throwOnNoExec)
at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start()
at System.Diagnostics.Process.Start(ProcessStartInfo startInfo)
at System.Diagnostics.Process.Start(String fileName, String arguments)
at PnP.PowerShell.Commands.Utilities.BrowserHelper.OpenBrowserForInteractiveLogin(String url, Int32 port, Boolean usePopup,
CancellationTokenSource cancellationTokenSource) in c:\PnPPowerShell\src\Commands\Utilities\BrowserHelper.cs:line 347
at PnP.PowerShell.Commands.Base.PnPConnection.<>c__DisplayClass100_0.<CreateWithInteractiveLogin>b__0(String url, Int32 port) in
c:\PnPPowerShell\src\Commands\Base\PnPConnection.cs:line 508
at PnP.Framework.Utilities.OAuth.DefaultBrowserUi.OpenBrowser(String url, Int32 port)
at PnP.Framework.Utilities.OAuth.DefaultBrowserUi.InterceptAuthorizationUriAsync(Uri authorizationUri, Uri redirectUri, CancellationToken
cancellationToken)
at PnP.Framework.Utilities.OAuth.DefaultBrowserUi.AcquireAuthorizationCodeAsync(Uri authorizationUri, Uri redirectUri, CancellationToken
cancellationToken)
at Microsoft.Identity.Client.UI.CustomWebUiHandler.AcquireAuthorizationAsync(Uri authorizationUri, Uri redirectUri, RequestContext
requestContext, CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.FetchAuthCodeAndPkceInternalAsync(IWebUI webUi, CancellationToken
cancellationToken)
at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.FetchAuthCodeAndPkceVerifierAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.GetTokenResponseAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.ExecuteAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync(CancellationToken cancellationToken)
at Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.ExecuteAsync(AcquireTokenCommonParameters commonParameters,
AcquireTokenInteractiveParameters interactiveParameters, CancellationToken cancellationToken)
at PnP.Framework.AuthenticationManager.GetContextAsync(String siteUrl, CancellationToken cancellationToken)
at PnP.Framework.AuthenticationManager.GetContext(String siteUrl, CancellationToken cancellationToken)
at PnP.PowerShell.Commands.Base.PnPConnection.CreateWithInteractiveLogin(Uri uri, String clientId, String tenantAdminUrl, Boolean
launchBrowser, AzureEnvironment azureEnvironment, CancellationTokenSource cancellationTokenSource, Boolean forceAuthentication, String
tenant) in c:\PnPPowerShell\src\Commands\Base\PnPConnection.cs:line 516
at PnP.PowerShell.Commands.Base.ConnectOnline.ConnectInteractive() in c:\PnPPowerShell\src\Commands\Base\ConnectOnline.cs:line 553
at PnP.PowerShell.Commands.Base.ConnectOnline.Connect(CancellationToken& cancellationToken) in
c:\PnPPowerShell\src\Commands\Base\ConnectOnline.cs:line 267
at PnP.PowerShell.Commands.Base.ConnectOnline.ProcessRecord() in c:\PnPPowerShell\src\Commands\Base\ConnectOnline.cs:line 208
at System.Management.Automation.Cmdlet.DoProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
Message : No such file or directory
Data : System.Collections.ListDictionaryInternal
Source : System.Diagnostics.Process
HResult : -2147467259
CategoryInfo : NotSpecified: (:) [Connect-PnPOnline], Win32Exception
FullyQualifiedErrorId : System.ComponentModel.Win32Exception,PnP.PowerShell.Commands.Base.ConnectOnline
InvocationInfo :
MyCommand : Connect-PnPOnline
ScriptLineNumber : 1
OffsetInLine : 1
HistoryId : 4
Line : connect-pnponline -url 'https://xxx.sharepoint.com/sites/xxx' -interactive
PositionMessage : At line:1 char:1
+ connect-pnponline -url 'https://xxx.sharepoint.com/sites/xxx' …
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
InvocationName : connect-pnponline
CommandOrigin : Internal
ScriptStackTrace : at <ScriptBlock>, <No file>: line 1
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 17 (8 by maintainers)
Should we close the issue then?