diff --git a/Commands/Base/SPOnlineConnectionHelper.cs b/Commands/Base/SPOnlineConnectionHelper.cs index c3d62018d..ca9bfccc9 100644 --- a/Commands/Base/SPOnlineConnectionHelper.cs +++ b/Commands/Base/SPOnlineConnectionHelper.cs @@ -562,6 +562,12 @@ internal static SPOnlineConnection InstantiateSPOnlineConnection(Uri url, PSCred { context.Credentials = new NetworkCredential(credentials.UserName, credentials.Password); } + else + { + // If current credentials should be used, use the DefaultNetworkCredentials of the CredentialCache. This has the same effect + // as using "UseDefaultCredentials" in a HttpClient. + context.Credentials = CredentialCache.DefaultNetworkCredentials; + } } #if SP2013 || SP2016 || SP2019 var connectionType = ConnectionType.OnPrem;