protected bool CheckIfInteractive()
{
bool interactive = true;
if (this.Host == null ||
this.Host.UI == null ||
this.Host.UI.RawUI == null ||
Environment.GetCommandLineArgs().Any(s =>
s.Equals("-NonInteractive", StringComparison.OrdinalIgnoreCase)))
{
interactive = false;
}
else
{
try
{
var test = this.Host.UI.RawUI.KeyAvailable;
}
catch
{
interactive = false;
}
}
if (!interactive && !_dataCollectionProfile.EnableAzureDataCollection.HasValue)
{
_dataCollectionProfile.EnableAzureDataCollection = false;
}
return interactive;
}