diff --git a/src/System.Management.Automation/engine/ExperimentalFeature/EnableDisableExperimentalFeatureCommand.cs b/src/System.Management.Automation/engine/ExperimentalFeature/EnableDisableExperimentalFeatureCommand.cs
index 2c9763dcd..35a404b67 100644
--- a/src/System.Management.Automation/engine/ExperimentalFeature/EnableDisableExperimentalFeatureCommand.cs
+++ b/src/System.Management.Automation/engine/ExperimentalFeature/EnableDisableExperimentalFeatureCommand.cs
@@ -30,6 +30,14 @@ namespace Microsoft.PowerShell.Commands
///
[Parameter]
public ConfigScope Scope { get; set; } = ConfigScope.CurrentUser;
+
+ ///
+ /// EndProcessing method.
+ ///
+ protected override void EndProcessing()
+ {
+ WriteWarning(ExperimentalFeatureStrings.ExperimentalFeaturePending);
+ }
}
///
@@ -87,8 +95,6 @@ namespace Microsoft.PowerShell.Commands
cmdlet.WriteError(new ErrorRecord(new ItemNotFoundException(errMsg), "ItemNotFoundException", ErrorCategory.ObjectNotFound, name));
return;
}
-
- cmdlet.WriteWarning(ExperimentalFeatureStrings.ExperimentalFeaturePending);
}
}
diff --git a/test/powershell/engine/ExperimentalFeature/EnableDisable-ExperimentalFeature.Tests.ps1 b/test/powershell/engine/ExperimentalFeature/EnableDisable-ExperimentalFeature.Tests.ps1
index 75f0fa49d..35792753f 100644
--- a/test/powershell/engine/ExperimentalFeature/EnableDisable-ExperimentalFeature.Tests.ps1
+++ b/test/powershell/engine/ExperimentalFeature/EnableDisable-ExperimentalFeature.Tests.ps1
@@ -94,4 +94,14 @@ Describe "Enable-ExperimentalFeature and Disable-ExperimentalFeature tests" -tag
& $cmdlet ExpTest.FeatureOne -WarningVariable warning -WarningAction SilentlyContinue
$warning | Should -Not -BeNullOrEmpty -Because "A warning message is always given indicating restart is required"
}
+
+ It "Multiple features enabled will only output one warning message for " -TestCases @(
+ @{ cmdlet = "Enable-ExperimentalFeature" },
+ @{ cmdlet = "Disable-Experimentalfeature" }
+ ) {
+ param ($cmdlet)
+
+ Get-ExperimentalFeature | & $cmdlet -WarningAction SilentlyContinue -WarningVariable warning
+ $warning | Should -HaveCount 1
+ }
}