.NET(#/VB), , , , . PowerShell. , , , , , :
[Parameter]
public ScriptBlock NewName { get; set; }
[Parameter(ValueFromPipeline = true)]
public string OldName { get; set; }
protected override void ProcessRecord()
{
Collection<PSObject> results = NewName.Invoke(this.OldName);
this.Host.UI.WriteLine("New name is " + results[0]);
}
, , , $_ , $args [0]. , , - .
OTOH, Rename-Item NewName , . NewName , (), PowerShell . , $_ , :
[Parameter(ValueFromPipelineByPropertyName = true)]
public string NewName { get; set; }
[Parameter(ValueFromPipeline = true)]
public string OldName { get; set; }
protected override void ProcessRecord()
{
this.Host.UI.WriteLine("New name is " + this.NewName);
}