I have an advanced function that that looks something like this:
function Audit-System
{
[CmdletBinding()]
param(
[Parameter(Position=0,Mandatory=$True,ValueFromPipeline=$True,ValueFromPipelinebyPropertyName=$True)]
[Alias("Name")]
[string[]]$ComputerName
)
Process
{
foreach($computer in $ComputerName)
{
## Do stuff for every computer
Write-Verbose $computer
}
}
}The followimg work ok:
"computer1","computer2" | Audit-System Audit-System "computer1","computer2" Audit-System "computer1"
The following doesn't work:
Get-ADComputer -Filter * SearchBase "CN=Computers,DC=contoso,DC=com" | Audit-System -VerboseI would have thought that because the [Microsoft.ActiveDirectory.Management.ADComputer] has a 'Name' property parameter binding would have matched it up with my $ComputerName parameter. Why doesn't this work?