I am new to PowerShell and I am trying to understand how to pass items through the pipeline to a custom function. For example, I have a CSV file that looks something like this:
Url,Email
"http://www.google.com","[email protected]"
"http://www.yahoo.com", "[email protected]"
and a function that looks somewhat like this:
Function HelloWorld() {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$Url,
[Parameter(Mandatory=$True)]
[string]$Email)
Proces {
Write-Host $Url $Email
}
}
I would like the command to work something like this:
Import-CSV C:\temp\myfile.csv | HelloWorld -Url {$.Url} -Email {$.Email}
However I am getting the following error:
HelloWorld : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
Understanding that I am new to PowerShell how would I get this simple example working?