Lazy Diary @ Hatena Blog

PowerShell / Java / miscellaneous things about software development, Tips & Gochas. CC BY-SA 4.0/Apache License 2.0

Entries from 2017-04-07 to 1 day

Mandatory parameter from pipeline, and empty lines

In a function that retrieve parameters from pipeline, if you make a parameter mandatory (Mandatory=$true), you will get error when an empty line is passed from the pipeline. If you receive parameters from the data which may contain empty l…

You cannot retrieve a required parameter from "either pipeline or argument"

## Context: A mandatory parameter of a function retrieved from pipeline is defined like this: param( [Parameter(ValueFromPipeline=$true, Mandatory=$true)] [string] $foo ) A mandatory parameter of a function retrieved from argument is defin…