Skip to content

Commit 7c3438e

Browse files
committed
CheckIfInteractive
1 parent 21b99bf commit 7c3438e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/Common/Commands.Common/AzurePSCmdlet.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ protected void PromptForDataCollectionProfileIfNotExists()
234234
// Initialize it from the environment variable or profile file.
235235
InitializeDataCollectionProfile();
236236

237-
if (!_dataCollectionProfile.EnableAzureDataCollection.HasValue)
237+
if (GeneralUtilities.CheckIfInteractive() && !_dataCollectionProfile.EnableAzureDataCollection.HasValue)
238238
{
239239
WriteWarning(Resources.DataCollectionPrompt);
240240

src/Common/Commands.Common/GeneralUtilities.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,5 +430,14 @@ public static void EnsureDefaultProfileDirectoryExists()
430430
AzureSession.DataStore.CreateDirectory(AzureSession.ProfileDirectory);
431431
}
432432
}
433+
434+
/// <summary>
435+
/// Check if the PS program is run in interactive mode.
436+
/// </summary>
437+
public static bool CheckIfInteractive()
438+
{
439+
var arguments = Environment.GetCommandLineArgs();
440+
return arguments.Any(s => !string.Equals(s, "-noninteractive"));
441+
}
433442
}
434443
}

0 commit comments

Comments
 (0)