File tree Expand file tree Collapse file tree 1 file changed +12
-13
lines changed
src/Common/Commands.Common Expand file tree Collapse file tree 1 file changed +12
-13
lines changed Original file line number Diff line number Diff line change @@ -254,28 +254,27 @@ protected void SaveDataCollectionProfile()
254254
255255 protected bool CheckIfInteractive ( )
256256 {
257- if ( this . Host == null || this . Host . UI == null || this . Host . UI . RawUI == null )
258- {
259- return false ;
260- }
261-
262257 bool interactive = true ;
263- try
258+ if ( this . Host == null || this . Host . UI == null || this . Host . UI . RawUI == null )
264259 {
265- var test = this . Host . UI . RawUI . KeyAvailable ;
260+ interactive = false ;
266261 }
267- catch ( HostException ex )
262+ else
268263 {
269- if ( ex . Message . StartsWith ( "A command that prompts the user failed" ) )
264+ try
270265 {
271- interactive = false ;
266+ var test = this . Host . UI . RawUI . KeyAvailable ;
272267 }
273- else
268+ catch
274269 {
275- throw ex ;
270+ interactive = false ;
276271 }
277272 }
278273
274+ if ( ! interactive && ! _dataCollectionProfile . EnableAzureDataCollection . HasValue )
275+ {
276+ _dataCollectionProfile . EnableAzureDataCollection = false ;
277+ }
279278 return interactive ;
280279 }
281280
@@ -288,7 +287,7 @@ protected void PromptForDataCollectionProfileIfNotExists()
288287 // Initialize it from the environment variable or profile file.
289288 InitializeDataCollectionProfile ( ) ;
290289
291- if ( CheckIfInteractive ( ) && ! _dataCollectionProfile . EnableAzureDataCollection . HasValue )
290+ if ( ! _dataCollectionProfile . EnableAzureDataCollection . HasValue && CheckIfInteractive ( ) )
292291 {
293292 WriteWarning ( Resources . DataCollectionPrompt ) ;
294293
You can’t perform that action at this time.
0 commit comments