@@ -537,7 +537,7 @@ public override void ExecuteCmdlet()
537
537
shouldPopulateContextList = false ;
538
538
}
539
539
540
- profileClient . WarningLog = ( message ) => _tasks . Enqueue ( new Task ( ( ) => this . WriteWarning ( message ) ) ) ;
540
+ profileClient . WarningLog = ( message ) => _tasks . Enqueue ( new Task ( ( ) => this . WriteWarning ( message ) ) ) ;
541
541
profileClient . InteractiveInformationLog = ( message ) => _tasks . Enqueue ( new Task ( ( ) => WriteInteractiveInformation ( message ) ) ) ;
542
542
profileClient . DebugLog = ( message ) => _tasks . Enqueue ( new Task ( ( ) => this . WriteDebugWithTimestamp ( message ) ) ) ;
543
543
profileClient . PromptAndReadLine = ( message ) =>
@@ -603,8 +603,28 @@ public override void ExecuteCmdlet()
603
603
}
604
604
} ) ;
605
605
606
- WriteInteractiveInformation ( $ "{ Resources . AnnouncementsHeader } { System . Environment . NewLine } { Resources . AnnouncementsMessage } { System . Environment . NewLine } ") ;
607
- WriteInteractiveInformation ( $ "{ Resources . ReportIssue } { System . Environment . NewLine } ") ;
606
+ WriteAnnouncementsPeriodically ( ) ;
607
+ }
608
+ }
609
+
610
+ private void WriteAnnouncementsPeriodically ( )
611
+ {
612
+ if ( ParameterSetName != UserParameterSet )
613
+ {
614
+ // Write-Host may block automation scenarios
615
+ return ;
616
+ }
617
+ const string AnnouncementsFeatureName = "SignInAnnouncements" ;
618
+ TimeSpan AnnouncementsInterval = TimeSpan . FromDays ( 7 ) ;
619
+ if ( AzureSession . Instance . TryGetComponent < IFrequencyService > ( nameof ( IFrequencyService ) , out var frequency ) )
620
+ {
621
+ frequency . Register ( AnnouncementsFeatureName , AnnouncementsInterval ) ;
622
+ // WriteInformation can't fail, so the second parameter always returns true
623
+ frequency . TryRun ( AnnouncementsFeatureName , ( ) => true , ( ) =>
624
+ {
625
+ WriteInformation ( $ "{ Resources . AnnouncementsHeader } { System . Environment . NewLine } { Resources . AnnouncementsMessage } { System . Environment . NewLine } ", false ) ;
626
+ WriteInformation ( $ "{ Resources . ReportIssue } { System . Environment . NewLine } ", false ) ;
627
+ } ) ;
608
628
}
609
629
}
610
630
@@ -878,7 +898,7 @@ private void AddConfigTelemetry()
878
898
AzConfigReader . GetAzConfig ( ConfigKeys . EnableLoginByWam , true ) . ToString ( ) ) ;
879
899
}
880
900
}
881
- catch ( Exception ex )
901
+ catch ( Exception ex )
882
902
{
883
903
WriteDebug ( string . Format ( "Failed to add telemtry for config as {0}" , ex . Message ) ) ;
884
904
}
0 commit comments