Repository: PowerShell/PowerShell
File: src/System.Management.Automation/engine/hostifaces/PowerShell.cs (C#)

Code before:
                }

                if (_psCommand.Commands.Count == 0)
                {
                    throw PSTraceSource.NewInvalidOperationException(PowerShellStrings.ParameterRequiresCommand);
                }

                AssertChangesAreAccepted();

                foreach (DictionaryEntry entry in parameters)
                {
                    if (!(entry.Key is string parameterName))
                    {
                        throw PSTraceSource.NewArgumentException(nameof(parameters), PowerShellStrings.KeyMustBeString);
                    }

                    _psCommand.AddParameter(parameterName, entry.Value);
                }

                return this;
            }
        }

        /// <summary>
        /// Adds an argument to the last added command.
        /// For example, to construct a command string "get-process | select-object name"
        ///     <code>
        ///         PowerShell shell = PowerShell.Create()
        ///             .AddCommand("get-process")
        ///             .AddCommand("select-object").AddArgument("name");
        ///     </code>
        /// This will add the value "name" to the positional parameter list of "select-object"
        /// cmdlet. When the command is invoked, this value will get bound to positional parameter 0
        /// of the "select-object" cmdlet which is "Property".
        /// </summary>
        /// <param name="value">
        /// Value for the parameter.
        /// </param>
        /// <returns>
        /// A PSCommand instance parameter value <paramref name="value"/> added
        /// to the parameter list of the last command.
        /// </returns>
        /// <remarks>
        /// This method is not thread safe.
        /// </remarks>
        public PowerShell AddArgument(object value)
        {
            lock (_syncObject)
            {
                if (_psCommand.Commands.Count == 0)
                {

Review comment (suggestion):
```suggestion
        /// For example, to construct a command string "Get-Process | Select-Object Name"
```

Code after:
                }

                if (_psCommand.Commands.Count == 0)
                {
                    throw PSTraceSource.NewInvalidOperationException(PowerShellStrings.ParameterRequiresCommand);
                }

                AssertChangesAreAccepted();

                foreach (DictionaryEntry entry in parameters)
                {
                    if (!(entry.Key is string parameterName))
                    {
                        throw PSTraceSource.NewArgumentException(nameof(parameters), PowerShellStrings.KeyMustBeString);
                    }

                    _psCommand.AddParameter(parameterName, entry.Value);
                }

                return this;
            }
        }

        /// <summary>
        /// Adds an argument to the last added command.
        /// For example, to construct a command string "Get-Process | Select-Object Name"
        ///     <code>
        ///         PowerShell shell = PowerShell.Create()
        ///             .AddCommand("Get-Process")
        ///             .AddCommand("Select-Object").AddArgument("Name");
        ///     </code>
        /// This will add the value "name" to the positional parameter list of "select-object"
        /// cmdlet. When the command is invoked, this value will get bound to positional parameter 0
        /// of the "select-object" cmdlet which is "Property".
        /// </summary>
        /// <param name="value">
        /// Value for the parameter.
        /// </param>
        /// <returns>
        /// A PSCommand instance parameter value <paramref name="value"/> added
        /// to the parameter list of the last command.
        /// </returns>
        /// <remarks>
        /// This method is not thread safe.
        /// </remarks>
        public PowerShell AddArgument(object value)
        {
            lock (_syncObject)
            {
                if (_psCommand.Commands.Count == 0)
                {