diff --git a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ConvertToJsonCommand.cs b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ConvertToJsonCommand.cs
index 36e8acdfd6..2e33a10096 100644
--- a/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ConvertToJsonCommand.cs
+++ b/src/Microsoft.PowerShell.Commands.Utility/commands/utility/WebCmdlet/ConvertToJsonCommand.cs
@@ -27,15 +27,13 @@ namespace Microsoft.PowerShell.Commands
private int _depth = 2;
- private const int maxDepthAllowed = 100;
-
private readonly CancellationTokenSource _cancellationSource = new();
///
/// Gets or sets the Depth property.
///
[Parameter]
- [ValidateRange(0, int.MaxValue)]
+ [ValidateRange(0, 100)]
public int Depth
{
get { return _depth; }
@@ -99,23 +97,7 @@ namespace Microsoft.PowerShell.Commands
_cancellationSource.Dispose();
}
}
-
- ///
- /// Prerequisite checks.
- ///
- protected override void BeginProcessing()
- {
- if (_depth > maxDepthAllowed)
- {
- string errorMessage = StringUtil.Format(WebCmdletStrings.ReachedMaximumDepthAllowed, maxDepthAllowed);
- ThrowTerminatingError(new ErrorRecord(
- new InvalidOperationException(errorMessage),
- "ReachedMaximumDepthAllowed",
- ErrorCategory.InvalidOperation,
- null));
- }
- }
-
+
private readonly List