I've noticed that most Powershell advanced functions declare parameters of standard datatypes (string, int, bool, xml, array, hashtable, etc.) which map to specific .Net types.
How would one declare an advanced function parameter using another .Net data type? For example, here is a contrived example:
function Do-Something
{
[CmdletBinding()]
Param(
[System.Xml.XPathNodeList] $nodeList
)
Begin {}
Process
{
Foreach ($node in $nodeList)
{
Write-Host $node
}
}
End {}
}
# Prepare to call the function:
$xml = [xml](get-content .\employee.xml)
$nodeList = $xml.SelectNodes("//age")
# Call the function passing an XPathNodeList:
do-something $nodeList
Invoking this function results in the following runtime error:
Unable to find type [System.Xml.XPathNodeList]: make sure that the assembly
containing this type is loaded.
Can this be accomplished with LoadWithPartialName()? How?
Assuming this is possible, here's an ancillary question: would using non-standard types this way go against 'best practice'?