diff --git a/src/System.Management.Automation/engine/InitialSessionState.cs b/src/System.Management.Automation/engine/InitialSessionState.cs index f19f8065298..f86b2869e5a 100644 --- a/src/System.Management.Automation/engine/InitialSessionState.cs +++ b/src/System.Management.Automation/engine/InitialSessionState.cs @@ -4186,36 +4186,18 @@ .FORWARDHELPCATEGORY Cmdlet ) begin { - - try { - $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('New-Item', [System.Management.Automation.CommandTypes]::Cmdlet) - $scriptCmd = {& $wrappedCmd -Type Directory @PSBoundParameters } - $steppablePipeline = $scriptCmd.GetSteppablePipeline() - $steppablePipeline.Begin($PSCmdlet) - } catch { - throw - } - + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('New-Item', [System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd -Type Directory @PSBoundParameters } + $steppablePipeline = $scriptCmd.GetSteppablePipeline() + $steppablePipeline.Begin($PSCmdlet) } process { - - try { - $steppablePipeline.Process($_) - } catch { - throw - } - + $steppablePipeline.Process($_) } end { - - try { - $steppablePipeline.End() - } catch { - throw - } - + $steppablePipeline.End() } "; @@ -4234,35 +4216,20 @@ internal static string GetOSTFunctionText() [psobject] ${InputObject}) -begin -{ - try { - $PSBoundParameters['Stream'] = $true - $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Out-String',[System.Management.Automation.CommandTypes]::Cmdlet) - $scriptCmd = {& $wrappedCmd @PSBoundParameters } - $steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin) - $steppablePipeline.Begin($PSCmdlet) - } catch { - throw - } +begin { + $PSBoundParameters['Stream'] = $true + $wrappedCmd = $ExecutionContext.InvokeCommand.GetCommand('Out-String',[System.Management.Automation.CommandTypes]::Cmdlet) + $scriptCmd = {& $wrappedCmd @PSBoundParameters } + $steppablePipeline = $scriptCmd.GetSteppablePipeline($myInvocation.CommandOrigin) + $steppablePipeline.Begin($PSCmdlet) } -process -{ - try { - $steppablePipeline.Process($_) - } catch { - throw - } +process { + $steppablePipeline.Process($_) } -end -{ - try { - $steppablePipeline.End() - } catch { - throw - } +end { + $steppablePipeline.End() } <# .ForwardHelpTargetName Out-String