Skip to content

Commit a9e0d8a

Browse files
committed
Fixed verbose message on DeviceLogin
1 parent 89498a4 commit a9e0d8a

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

src/Commands/Base/ConnectOnline.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public class ConnectOnline : BasePSCmdlet
165165
[Parameter(Mandatory = true, ParameterSetName = ParameterSet_APPONLYAADTHUMBPRINT)]
166166
[Parameter(Mandatory = true, ParameterSetName = ParameterSet_APPONLYAADCERTIFICATE)]
167167
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_INTERACTIVE)]
168-
[Parameter(Mandatory = true, ParameterSetName = ParameterSet_DEVICELOGIN)]
168+
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_DEVICELOGIN)]
169169
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_ENVIRONMENTVARIABLE)]
170170
[Parameter(Mandatory = false, ParameterSetName = ParameterSet_OSLOGIN)]
171171
public string Tenant;
@@ -530,7 +530,7 @@ private PnPConnection ConnectSpoManagement()
530530
/// </summary>
531531
/// <returns>PnPConnection based on the parameters provided in the parameter set</returns>
532532
private PnPConnection ConnectDeviceLogin()
533-
{
533+
{
534534
WriteVerbose("Connecting using Device Login");
535535

536536
var messageWriter = new CmdletMessageWriter(this);

src/Commands/Base/PnPConnection.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ internal static PnPConnection CreateWithDeviceLogin(string clientId, string url,
298298
if (msalServiceException.Message.StartsWith("AADSTS50059:"))
299299
{
300300
cancellationTokenSource.Cancel();
301-
throw new Exception("Please specify -Tenant with either the tenant id or hostname.");
301+
throw new Exception("Default authentication request failed. Please specify the -Tenant parameter with either the tenant id or hostname to authenticate.");
302302
}
303303
else
304304
{

src/Commands/Utilities/CmdletMessageWriter.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public void WriteWarning(string message, bool formatted = true)
7070
{
7171
lock (LockToken)
7272
{
73+
7374
Queue.Enqueue(new Message() { Formatted = formatted, Text = message, Type = MessageType.Warning });
7475
}
7576
}
@@ -84,9 +85,12 @@ public void WriteMessage(string message, bool formatted = true)
8485

8586
public void WriteVerbose(string message)
8687
{
87-
lock (LockToken)
88+
if (Cmdlet.MyInvocation.BoundParameters.ContainsKey("Verbose"))
8889
{
89-
Queue.Enqueue(new Message() { Formatted = false, Text = message, Type = MessageType.Verbose });
90+
lock (LockToken)
91+
{
92+
Queue.Enqueue(new Message() { Formatted = false, Text = message, Type = MessageType.Verbose });
93+
}
9094
}
9195
}
9296

0 commit comments

Comments
 (0)