If I create an object with a pstypename then I can enforce parameters to a function as being of that type, like so:
function New-NugetDependency{
Param(
[string]$Id,
[string]$Version
)
[PSCustomObject]@{
PSTypeName = "NuGetDependency"
ID = $ID
Version = $Version
}
}
and
function Show-NugGetDependency{
Param(
[PSTypeName("NuGetDependency")]$Dependency
)
Write-Host ("Dependency is " + $Dependency.id + " - " + $Dependency.Version)
}
However! There doesn't seem to be any way of saying that $Dependency is an array of NuGetDependency. So if I wanted the function to take in multiple dependencies then I'm stuck.
What am I missing?