/********************************************************************++ Copyright (c) Microsoft Corporation. All rights reserved. --********************************************************************/ using System.Management.Automation; namespace Microsoft.PowerShell.Commands { #region WriteOutputCommand /// /// This class implements Write-output command /// /// [Cmdlet("Write", "Output", HelpUri = "https://go.microsoft.com/fwlink/?LinkID=113427", RemotingCapability = RemotingCapability.None)] public sealed class WriteOutputCommand : PSCmdlet { private PSObject[] _inputObjects = null; /// /// Holds the list of objects to be Written /// [Parameter(Position = 0, Mandatory = true, ValueFromPipeline = true, ValueFromRemainingArguments = true)] [AllowNull] [AllowEmptyCollection] public PSObject[] InputObject { get { return _inputObjects; } set { _inputObjects = value; } } /// /// Prevents Write-Output from unravelling collections passed to the InputObject /// parameter. /// [Parameter()] public SwitchParameter NoEnumerate { get; set; } /// /// This method implements the ProcessRecord method for Write-output command /// protected override void ProcessRecord() { if (null == _inputObjects) { WriteObject(_inputObjects); return; } bool enumerate = true; if (NoEnumerate.IsPresent) { enumerate = false; } foreach (PSObject inputObject in _inputObjects) // compensate for ValueFromRemainingArguments { WriteObject(inputObject, enumerate); } }//processrecord }//WriteOutputCommand #endregion }